How to use union just once with where command?

前端 未结 1 845
温柔的废话
温柔的废话 2021-01-27 10:55

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 get

1条回答
  •  终归单人心
    2021-01-27 11:43

    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
    

    0 讨论(0)
提交回复
热议问题