开发者

using two tables with mysql

$sql = "SELECT * FROM `basic` WHERE id = 2 LIMIT 0, 30"; 

i want to retrieve data from 'users' table in the same query. fields of users table are

1.country

2.name

3.userid

basic table consist of selling items and there are unique id for each one. also users table consist of users and there are uni开发者_运维百科que id for each one.

if i say i want data from basic table where id is 4 and user's table where id is 15 in same query....how should i rewrite above mysql statement


May be you need to read this JOIN.Try to read some tutorials that can help you improving your programming knowledge.


$sql=SELECT *
        FROM `basic` as b inner join `table2` as c
        WHERE b.id =c.id
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜