-1
I have a table that has the following structure:
origem|papel|campo018|campo040|mercado|Master_key|
The column Master_key
can have two values: 'NY'
OR 'MS'
, I would like to compare the lines where Master_key is equal to 'NY'
with those who are 'MS'
, the source, paper and market columns are keys.
I tried this way, but it didn’t 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');
I don’t understand what you want but it sure ain’t with
INNER JOIN
, it serves to make queries joining different tables. Could give an expected output example?– Costamilam
I added an example to the question
– Geraldão de Rívia
The relationship between the two rows is if all columns are equal however
Master_key
different?– Costamilam
@Guillhermecostamilam
Master_key
can only have two results, so it has a Where at the end of the query– Geraldão de Rívia