[Resolved Issue] Sql Syntax Needed - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › [Resolved Issue] Sql Syntax Needed (966 Views)
1 (Go Down)
| [Resolved Issue] Sql Syntax Needed by BigStar1(op): 9:48pm On Nov 20, 2012 |
Dear everyone, please I need to select some values from a table(A), but those records must not be contained in another table(B). I.e. All records in A that are not in B. Thanks |
| Re: [Resolved Issue] Sql Syntax Needed by naijaswag1: 1:45pm On Nov 21, 2012 |
Try using set notation for sql: union,minus or intersect will do that for you. I know these are supported on oracle. For this situation, minus will do. |
| Re: [Resolved Issue] Sql Syntax Needed by saintiyke(m): 6:28pm On Nov 21, 2012 |
U can use JOIN or write a subquery. ......... E.g. Using subqueries; SELECT columnA,...., FROM TableA WHERE ( SELECT columnB, ......, FROM TableB); |
| Re: [Resolved Issue] Sql Syntax Needed by saintiyke(m): 6:31pm On Nov 21, 2012 |
saintiyke: U can use JOIN or write a subquery. ......... E.g. Using subqueries;. ....... Represents other columns u might want to select. |
| Re: [Resolved Issue] Sql Syntax Needed by saintiyke(m): 6:33pm On Nov 21, 2012 |
In using JOIN, u must know the primary key and the foreign key of each table |
| Re: [Resolved Issue] Sql Syntax Needed by BigStar1(op): 3:01pm On Nov 22, 2012 |
Many thanks to you all for your contribution. I have tried using Join before posting it on NL. I was not getting it right. Can you just help me post the query here. Thanks |
| Re: [Resolved Issue] Sql Syntax Needed by Listener10: 10:53pm On Nov 22, 2012*. Modified: 11:29pm On Nov 22, 2012 |
try this if it will work. Select column1,column2,... From tableA Minus Select column1,column2,... From tableB; |
| Re: [Resolved Issue] Sql Syntax Needed by Nobody: 11:15pm On Nov 22, 2012 |
I'm learning. |
| Re: [Resolved Issue] Sql Syntax Needed by saintiyke(m): 8:35am On Nov 23, 2012 |
Listener10: try this if it will work. Select column1,column2,... From tableA Minus Select column1,column2,... From tableB;where is the relationship between TableA and TableB ? I dont think it worths trying as u will surely get an error |
| Re: [Resolved Issue] Sql Syntax Needed by Listener10: 9:12am On Nov 23, 2012 |
saintiyke: where is the relationship between TableA and TableB ? I dont think it worths trying as u will surely get an errorguy,the op didnt state d relationship btw d two tables. We dont know d structure of the two tables.you can only write out the relationship btw two tables when u know their structures.the op only asked for d syntax and not d actual statement.he'll be d one to complete d statements since he's d only person that knows d structure of d tables.what i gave is just a clue.how do u expect me to know d relationship btw two tables when i dont know d primary key or d foreign keys of d tables |
| Re: [Resolved Issue] Sql Syntax Needed by Nobody: 10:56am On Nov 23, 2012 |
Big Star: Dear everyone, please I need to select some values from a table(A), but those records must not be contained in another table(B). I.e. All records in A that are not in B. Thanksare you trying to select from table A only, the values not in table B then you may want to use subqueries SELECT * FROM tableA WHERE tableA.id not in (select id from tableB) |
| Re: [Resolved Issue] Sql Syntax Needed by BigStar1(op): 3:07pm On Nov 23, 2012 |
webdezzi: SELECT * FROM tableA WHERE tableA.id not in (select id from tableB)Wow! Thanks so much. This code works like magic. @moderators, kindly provide a button for marking a post as resolved. Thanks everybody. |
| Re: [Resolved Issue] Sql Syntax Needed by mitey(m): 11:39am On Nov 24, 2012 |
Big Star: Wow! Thanks so much. This code works like magic. @moderators, kindly provide a button for marking a post as resolved. Thanks everybody.Simply modify the topic and add [Solved] at the beginning. |
Programming Your Own Code Syntax Highlighter • Java Syntax Highlighter For Smf 1.0.12 • Parse Error: Syntax Error, Unexpected T_else In C:\ • 2 • 3 • 4
NS2 Simulations In Linux OS, Any Idea? • Joomla Help Asap • Start Your Dream Ecommerce Website