如何使用where命令一次使用union? [英] How to use union just once with where command?
本文介绍了如何使用where命令一次使用union?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在2 tables
中使用where
命令where notifikasi = '1'
在php中使用查询,但是我只看到1张表,该表获得where notifikasi = '1'
,我该如何使我的两个桌子都得到where notifikasi = '1'
?
I want to use a query in php with where
command where notifikasi = '1'
in the 2 tables
, but I only see 1 table that gets where notifikasi = '1'
, how can I make both my tables get where notifikasi = '1'
?
SELECT a.id_skd as idab,a.nl as nl1, a.aa as aa1,a.jp as jp1, a.syarat_lampiran as syarat_lampiran1,a.riwayat_kelola as riwayat_kelola1,a.notifikasi as notifikasi1
FROM skd a
UNION ALL
SELECT b.id_skb as idab, b.nl as nl1, b.aa as aa1, b.jp as jp1, b.syarat_lampiran as syarat_lampiran1,b.riwayat_kelola as riwayat_kelola1, b.notifikasi as notifikasi1
FROM skb b
WHERE notifikasi='1'
ORDER BY riwayat_kelola1 DESC
LIMIT 1
推荐答案
您必须重复WHERE
子句,它仅适用于一个SELECT
查询,而不适用于整个UNION
.
You have to repeat the WHERE
clause, it only applies to one SELECT
query, not the whole UNION
.
SELECT a.id_skd as idab,a.nl as nl1, a.aa as aa1,a.jp as jp1, a.syarat_lampiran as syarat_lampiran1,a.riwayat_kelola as riwayat_kelola1,a.notifikasi as notifikasi1
FROM skd a
WHERE notifikasi = '1'
UNION ALL
SELECT b.id_skb as idab, b.nl as nl1, b.aa as aa1, b.jp as jp1, b.syarat_lampiran as syarat_lampiran1,b.riwayat_kelola as riwayat_kelola1, b.notifikasi as notifikasi1
FROM skb b
WHERE notifikasi='1'
ORDER BY riwayat_kelola1 DESC
LIMIT 1
这篇关于如何使用where命令一次使用union?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文