[英]how combine 2 query into 1 query with mysql
首先,抱歉我的英語不好。
這是我的數據mysql:
id | tx_command | tx_status
-----------------------------
1 | postpaid | OK
2 | prepaid | OK
3 | cek | OK
4 | cek | NOK
5 | view_voucher| OK
6 | postpaid | NOK
7 | prepaid | NOK
這對我來說是問題和困難。 我想顯示基於數據- Tx_command 'postpaid and prepaid' 與 tx_status 'ok' ,然后即使后付費或預付費 tx_command 但他的 tx_status 'NOK' 然后不顯示。 - 第二個是我想用 tx_status 'NOK' 顯示 tx_command 'cek',換句話說,如果 tx_command 'cek' 和 tx_status 'NOK' 然后不顯示。
如果將兩者都制成一個查詢是否可以?
是的,您可以使用OR
條件...
像這樣的東西
SELECT
*
FROM
<your-table>
WHERE
(tx_command = 'prepaid' AND tx_status = 'OK') OR
(tx_command = 'prepaid' AND tx_status = 'OK') OR
(tx_command = 'cek' AND tx_status = 'NOK')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.