Answer the question
In order to leave comments, you need to log in
How to select records in sql, knowing their id?
I have a table that stores links to favorite articles by users. To select the id of all the posts that the user has marked as favorite, you need to apply this code:
SELECT `targetid` FROM `chosenlink` WHERE `type`=1 AND `userid`=".$userinfo['id']
Answer the question
In order to leave comments, you need to log in
The question is a little not clear
So far, we can say for sure that the search is done like this. You just have to substitute your set of idsselect * from table where id in (1, 2, 3, 4 ....)
If, of course, I correctly understood the question, then you need JOIN , something like this:
SELECT `t2`.* FROM `chosenlink` `t1` JOIN `table` `t2` ON `t1'.`targetid` = `t2`.`id` WHERE `type`=1 AND `userid`=".$userinfo['id']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question