select的嵌套用法:
例子:
如果要从表userinfo(此表也含有userid)中选出与表result的userid不同的所有数据,例子如下:
引用
select A from (select * from tableB) as t1
或者
select A from (select * from tableB) t1
或者
select A from (select * from tableB) t1
例子:
引用
SELECT *
FROM (
SELECT *
FROM affiche
ORDER BY `submit_date` DESC
) AS t1
GROUP BY type_id
ORDER BY `submit_date` DESC
LIMIT 0 , 30
FROM (
SELECT *
FROM affiche
ORDER BY `submit_date` DESC
) AS t1
GROUP BY type_id
ORDER BY `submit_date` DESC
LIMIT 0 , 30
如果要从表userinfo(此表也含有userid)中选出与表result的userid不同的所有数据,例子如下:
引用
select * from userinfo where userinfo.userid not in(select result.userid from result)