I have two tables
table 1 : id, name, age, gender.
table 2(friend) : id1,id2. (stored only once i.e only one entry for a unique pair)
I need to write a query that takes an id and then return the result set containing the rows from table 1 corresponding to all his/hers friend.
I tried this Query
"SELECT * FROM table1 WHERE id IN ("
+ "(SELECT id2 FROM table2 WHERE (id1="+given_id+")) UNION "
+ "(SELECT id1 FROM table2 WHERE (id2="+given_id+")));"
but it does’nt seem to work says syntax error … could anyone help me with this query.
Efforts appreciated … Thanks a lot
You can do something similar to this.