I want to fetch a data from two tables even if the second table has no data. I need empty values for no data.
For e.g. table 1 has the fields
- id
- name
- password
table 2 has
- id(foreign key refer id from table 1)
- f1
- f2
- f3
Some time table 2 doesn’t have the value for a particular user. For that I need the null values.
Here I give sample input and expected output
table1
id name password
1 nam1 pass1
2 nam2 pass2
table 2
id f1 f2 f3
1 1 2 3
sample output
id name password f1 f2 f3
1 nam1 pass1 1 2 3
2 nam2 pass2 null null null
I need a query to fetch a data.
You need
SELECTwithLEFT JOINSample query will be like: