'Joining results from two tables
I have two tables
CREATE TABLE person AS (
id INTEGER,
sa VARCHAR2
)
CREATE TABLE sampletest AS (
sa VARCHAR2,
cell VARCHAR2,
pd VARCHAR2
)
I would like to get this output
SA | CELL | PD
this works:
SELECT person.*,
sampletest.*
FROM person
INNER JOIN sampletest
ON person.sa = sampletest.sa;
but I want to condition this like:
SELECT person.*,
sampletest.*
FROM person
WHERE person.sa = "S123"
INNER JOIN sampletest
ON person.sa = sampletest.sa;
but this does not work...
Solution 1:[1]
You need to pospone the WHERE
condition:
SELECT
person.*,
sampletest.*
FROM
person
INNER JOIN
sampletest
ON
person.sa = sampletest.sa
WHERE
person.sa = "S123";
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | lemon |