0
id  -  in_id  -  nat_id
1      1         1     
2      1         3     
3      3         3     
4      2         1     

Is it possible to select with mysql only the values in the above table which are the same across the 3 columns, ie return 1 and 3?

Or is this kind of filter only possible post query with php?

Thanks, John

4

1 回答 1

1

这个简单的查询应该适合您:

SELECT id
  FROM your_table
WHERE id = in_id
  AND nat_id = in_id
;

在 SQLFiddle 检查示例:SQLFiddle Example

于 2013-11-06T23:01:24.990 回答