两个表的数据对比有关问题(php+mysql)

WBOY
Release: 2016-06-13 13:52:57
Original
936 people have browsed it

求助:两个表的数据对比问题(php+mysql)
table_a
id,code
1,xiaoming
2,daniu
3,sige
5,wangqiang
6,liming

table_b
id,aid
1,2
2,3
3,6
我要显示效果如下,在B表中对应的A表内容高亮显示:
1,xiaoming
2,daniu
3,sige
5,wangqiang
6,liming

请教高手,如何解决。

------解决方案--------------------
select a.id,a.code,b.aid from a outer join b on a.id = b.id order by a.id asc
然后判断b.aid有值则高亮显示即可。
------解决方案--------------------
楼上的方法可行
------解决方案--------------------
SELECT 
a.id, a.code, 
(CASE WHEN b.id IS NULL THEN 'N' ELSE 'Y' END)AS IsHight
FROM
a
LEFT JOIN b ON a.id = b.id 
ORDER BY a.id 

当IsHeight值为‘Y’的话,则加亮显示

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!