简体   繁体   中英

SQL rows sharing same column value and with where

表

For MySQL, From the given table, I am interested in all rows that have CASE_ID=1510001, but also the rows that share same MESSAGE_ID.

Eg: If CASE_ID=1510001

Output has to be below. The SQL has to take a input CASE_ID. Thank you for the suggestions.

在此处输入图片说明

Try:

SELECT * FROM given_table WHERE message_id IN (SELECT message_id FROM given_table WHERE case_id = 1510001);

MySQL subquery

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM