| | |
SQL Query Help needed!
Please support our MS SQL advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2006
Posts: 21
Reputation:
Solved Threads: 0
•
•
•
•
you need to do an inner join if you are not wanting to list all in the tables that share the record ids.
This is the inner join sql:
MS SQL Syntax (Toggle Plain Text)
SELECT * FROM TBL_ComponentList c INNER JOIN TBL_Modules m ON m.Identifier=c.CompIdentifierID AND c.CreatedBy = '2418' AND m.identifier IN ('1','2','3','4','5','6')
If i do it as 2 separate sql, i get what i need but i need to make it as 1. The 2 sql that i need to join is
MS SQL Syntax (Toggle Plain Text)
1) SELECT * FROM TBL_Modules WHERE identifier IN ('1','2','3','4','5','6') ORDER BY Identifier 2) SELECT * FROM TBL_Modules m,TBL_ComponentList c WHERE m.Identifier=c.CompIdentifierID AND c.CreatedBy = '2418' ORDER BY m.Identifier
the identifier id 1 to 6 doesnt exist in table componentlist.
Any help pls?
•
•
Join Date: Feb 2008
Posts: 42
Reputation:
Solved Threads: 13
You can combine your 2 query with 'UNION ALL' or 'UNION' like below:
MS SQL Syntax (Toggle Plain Text)
SELECT * FROM TBL_Modules WHERE identifier IN ('1','2','3','4','5','6') ORDER BY Identifier union ALL SELECT m.* FROM TBL_Modules m,TBL_ComponentList c WHERE m.Identifier=c.CompIdentifierID AND c.CreatedBy = '2418' ORDER BY m.Identifier
Hence Wijaya
www.ex-Soft.tk
www.ex-Soft.tk
![]() |
Similar Threads
- SQL SERVER 2000 Selecting a record based on an aggregate function (MS SQL)
- mysql and php display commands help needed (MySQL)
- Speed of member profiles (DaniWeb Community Feedback)
- cannot understand why i am getting the wrong results. (Oracle)
- WizardSteps-> SQL Insert -> Grab ID field (ASP.NET)
- MySql jump / click counter script help needed from a Newbie (MySQL)
- Help needed VERY MUCH (ASP.NET)
- OleDbDataReader error (C#)
- Unexpected T_STRING? (PHP)
- what does this code do? (PHP)
Other Threads in the MS SQL Forum
- Previous Thread: SQL Command Misbehaving under VStudio 2005
- Next Thread: How to retrieve table names
| Thread Tools | Search this Thread |






