I'd like to
SELECT DISTINCT column1, column2 as t1
And i'd like to
SELECT column3 FROM table2 WHERE column4 = "1" AND column3 = (matches)t1.column1
How should my query look like?
SELECT DISTINCT column1, column2 FROM table1 as t1,
column3 FROM table2 WHERE column4 = "1" AND column3 = t1.column1
The result should be a list with data from column1, that matches data from column3 AND column4 = 1
Table1: Table2:
-----------------------------------------
column1 column2 column3 column4
-----------------------------------------
001 Name 001 1
002 Name 002 0
003 Name 004 1
005 Name 005 1
-----------------------------------------
Result: 001, 005
Error:
Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FROM table2 WHERE column4 = '1' AND column3 = t1.column1' at line 1