I have the following table design:
What I want to do is, I need to select the email of two uIDs(which I'll pass in the query, say uID1 and uID2) and also, the content_title and cID which belongs to one of the uIDs that I pass(here, I'll pass the cID also).Code:Table1 --------------- uID | Email --------------- 1 | [email protected] 2 | [email protected] 3 | [email protected] 4 | [email protected] Table2 --------------- cID |uID | Content_title --------------- 1 | 1 | abc1 2 | 1 | abc2 3 | 2 | abc3 4 | 3 | abc4 5 | 3 | abc5 6 | 3 | abc6 etc..
Did I made it complicated ?
What I'll pass in the query is:
- uID of first user (uID1)
- uID of second user (uID2)
- cID of second user (ie. of uID2)
This should return:
- email of first user (uID1)
- email of second user (uID2)
- content_title of the second user from Table2 (ie. of uID2. The cID that I pass will be validated in this part. I mean, the cID that I passed in the query, should belongs exactly to the uID2. Otherwise, empty field is returned.)
What I have tried so far (and working):
Example:Code:SELECT * FROM ( (SELECT uID FROM Table1 WHERE uID = '1' LIMIT 1) AS email1, (SELECT uID FROM Table1 WHERE uID = '3' LIMIT 1) AS email2 )
I'll pass uID1 = '1' , uID2 = '3' and cID = '4'
Then it should return:
Any ideas ?Code:[email protected] | [email protected] | 4 | abc4
Thanks![]()






Reply With Quote