Jump to content
  • Advertisement
Sign in to follow this  
cignox1

simple SQL query

This topic is 4811 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well, I never used SQL deeply, but I never thought that one day I would have a problem like this. I have a database with many tables. Two of them are as follows: #1: Session_ID Item Time ... where Session_ID is a number and Item is a string (I don't need Time). #2 FromFile Link where FromFile is a number and Link a string. #1 rows are a list of used links, and #2 rows are the complete list of available links and the files they belongs. I need to know the FromFile property for each row in #1, so I did the following queries: select FromFile,Link from #2,#1 where #2.Link = #1.Item select FromFile,Link from #2 where Link = any (select Item from #1 where 1) I tried even more queries but the results are always wrong (I think) because I espect to get 1532 rows in the result (same than #1) but I get always repetitions (T get > 20000 rows), and I don't know why.

Share this post


Link to post
Share on other sites
Advertisement
Thank you for replying, but even with your query I get 20252 rows (always the same number, I think) where I espect exactly 1537 entries (one for each entry in #1 table).
Is this strange or am I missing something?

If this can help, I'm using MySQL with SQLyog as the client.
If I add the keyword distinct, I get 9704 rows... But in those 1537 I espect there could be easily duplicates.

Share this post


Link to post
Share on other sites
If you are getting back more records than exist in table #1, then you don't have a one-to-one relationship between the two tables, which seems to be what you're expecting. Either the #1.Item column or the #2.Link column has duplicate data.

-Halo7

Share this post


Link to post
Share on other sites
I used the following queries:
select * from #1 where 1
select distinct * from #1 where 1

both return the same results, so I think there are no duplicates.
In the #2 table I'm sure there are no duplicates, because it is a list of available links.
For such a simple task it is becoming to much complex :-(

EDIT: Ok, solved. The guy that gave me the db didn't explain it correctly. #2 contains duplicated links, in different files. I didn'checked until now, so sorry for this. Thank you anyway!

[Edited by - cignox1 on September 15, 2005 2:31:20 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!