whosmer Posted September 18, 2019 Share Posted September 18, 2019 I have a table (Table1) where one of the columns is the ID (Table2ID) for a second table (Table2). I know how to query Table1 and get all of the values, my issue is to be able to return the corresponding Name from table 2. I'm stumbling over NULL and available ID. Any assistance would be appreciated. Thanks! Link to comment Share on other sites More sharing options...
Ingolme Posted September 18, 2019 Share Posted September 18, 2019 You can LEFT JOIN the tables. Of course, wherever there's a NULL, all you'll get is NULL for the fields in table 2. If you want to completely ignore NULL rows, a plain JOIN will do that. Link to comment Share on other sites More sharing options...
whosmer Posted September 19, 2019 Author Share Posted September 19, 2019 Thanks! After several attempts and revisions, the script is working the way I want it do! Link to comment Share on other sites More sharing options...
shaili_shah Posted January 30, 2020 Share Posted January 30, 2020 If you want to show null value then you have to try this query : select t1.table1id, t1.table2id, t2.table2name from table1 t1 left join table2 t2 on t1.table2id = t2.table2id ; If you do not want to show that null values then use this query : select t1.table1id, t1.table2id, t2.table2name from table1 t1 inner join table2 t2 on t1.table2id = t2.table2id ; I hope this will show you your desired answer. let me know if you do this. Link to comment Share on other sites More sharing options...
Ingolme Posted January 31, 2020 Share Posted January 31, 2020 That's exactly what I said. Link to comment Share on other sites More sharing options...
dsonesuk Posted January 31, 2020 Share Posted January 31, 2020 Haven't you noticed? That's all they do! Shah twins and now sherin too. They copy the solutions from previous posters, none of them have contributed a solution to the forum by themselves. Link to comment Share on other sites More sharing options...
Ingolme Posted February 2, 2020 Share Posted February 2, 2020 I have been aware, yes. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now