I have a table that has the following structure:
origem|papel|campo018|campo040|mercado|Master_key|
The Master_key
column can have two values: 'NY'
OR 'MS'
, I'd like to compare the rows in which Master_key is equal to 'NY'
with those that are 'MS'
, the source, role, and market columns are keys.
I tried this way, but it did not work:
SELECT ny.*, ms.* FROM z_quotes ny
INNER JOIN z_quotes ms ON ny.origem = ms.origem
INNER JOIN z_quotes ms ON ny.papel = ms.papel
INNER JOIN z_quotes ms ON ny.mercado = ms.mercado
WHERE (ny.Master_key = 'NY') AND (ms.Master_key = 'MS');