我有两张桌子。结构是:
mysql> desc working;
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| worker_id | varchar(12) | YES | | NULL | |
| worker_duty | varchar(30) | YES | | NULL | |
| salary | varchar(8) | YES | | NULL | |
+-------------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> desc users;
+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| user_id | varchar(12) | YES | | NULL | |
| user_name | varchar(21) | YES | | NULL | |
| discription | varchar(200) | YES | | NULL | |
+-------------+--------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
我想使用worker_id
and加入这两个表并user_id
使用 PHP 获取它。
我用 :
SELECT * from users t1
WHERE user_id="293274"
AND SELECT worker_duty ,worker_id from working t2
WHERE t1.user_id= t2.worker_id
但是这段代码不起作用。