Click here to Skip to main content
15,936,903 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello dears

I have one database with two tables (record_table,attachments)

ID, subject,note

ID, ID_record_table,path

relationship between tables:
the = attachment.ID_record_table

but when one row in record_table has 2 attachment .and when I use select statement i will see 2 results for the same row in record_table. so how can I prevent duplicate rows.

(SELECT * FROM record_table LEFT JOIN attachment on = attachment.ID_record_table)
Updated 15-Jan-16 8:44am
Maciej Los 15-Jan-16 14:52pm    
Hhmmmmm.... What's an issue?

Since you're joining the two tables you will get as many rows in the result set how many rows satisfy the join condition. In other words, if one record has two attachments, two rows are returned.-

The rows aren't duplicates. If you have a look at the columns coming from attachment table you see that the contain the values from both rows.

Have a look at Visual Representation of SQL Joins[^]
Share this answer
Maciej Los 15-Jan-16 15:00pm    
Mika, i think you misunderstod the prblem. In my opinion OP wants to check if attachment extists in attachments table, but... i'm not sure.
Wendelius 15-Jan-16 15:05pm    
Thanks for the comment. That is one possibility, but I'm afraid that there is a misunderstanding what a join actually does. This is why I suggest going through the join types. Hopefully the OP responds if I've misunderstood the situation :)
Maciej Los 15-Jan-16 15:07pm    
Yeah, it's true. This might be a problem too.
Maciej Los 17-Jan-16 5:00am    
You were right, so have a 5!
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900