mysql - Join 3 tables with a limit -
i have created query select entries table timeline , enrich data users table. select (1) entry media.filename media table media.album = '0', result of query returning want returns entries media table , need one. put condition or limit 1 ?
select dat, sourceinfo, users.firstname, users.lastname, users.token, users.prof, media.filename timeline join users on users.user_id = timeline.userid2 join media on users.user_id = timeline.userid2 (timeline.user_id = '25') , (dat between date_add(now(), interval -1 day) , now())
thanks lot
put limit
clause in subquery.
select dat, sourceinfo, users.firstname, users.lastname, users.token, users.prof, media.filename timeline join users on users.user_id = timeline.userid2 cross join (select filename media album = 0 limit 1) media
or can put subquery in select
clause:
select dat, sourceinfo, users.firstname, users.lastname, users.token, users.prof, (select filename media album = 0 limit 1) filename timeline join users on users.user_id = timeline.userid2
Comments
Post a Comment