Wednesday 15 September 2010

mysql - Selecting data from different rows in the same table with a single statement -


I am selecting data from two different rows in the same table using a single table. "ID" "borrowed MX" "holder" "category" "country" "1" "2" "0" "3" "US" "2" "0" "1" "10" "US"

What I'm trying to do is it works. Choose ID, holder with mytable where id = 2 is borrowed from mytable id = ( from the holder) SELECT col1.id, col1.holder, col2.borrowMax from collection_db col1 zone collection_db col2 ON Col2.holder = col1.id WHERE col1.id = 2 // here, 2 value given by me and col2.category = 3

Of course, it works but since this is something I have done it together, I doubt it how will you do something like this? Am I on the right track? (I am sure I'm not the one.)

I use a case similar to nested selectors already There is no active work to be set of filtered results and logically used on a more consistent code.

  Choose my holder from the holder ID, WHERE id = (SELECT holder with mytable WHERE Id = 2) and category = 3    

No comments:

Post a Comment