Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a table called Testdata from database1 with following columns : itemid, item, state (this can be OK or Not OK) and employeeID. I make an innerjoin between employeeID from this table and employeeID from an other table called Employee from database 2. From that table I want to see the employee_name. What I want to get is every item that is OK. Every Item can be more then once in the table so when an item is 2 times in the table and is 2 times OK I get it 2 times in my datagrid. So I want to use the SELECT DISTINCT method but then I get an error. My question is : Can I always use DISTINCT or isn't it possible to use this when I'm also using INNERJOIN? I'm asking this because in an other case I can use DISTINCT but then I don't use an INNERJOIN.

Or can't I use it because I'm working with 2 tables out of 2 different databases?

Can someone give me an answer on this, please?

 

PS at the moment the first database is in Acces. The second is already copied to SQLserver.

  • *Experts*
Posted

You can use DISTINCT pretty much anywhere, including inner and outer joins and you should be able to do it across databases. Can you post your SQL so we can take a look - much easier to debug it if I can see it.

 

Also, where is the query "at"? In access with a link table to SQL Server, or is there a remote server in SQL Server that points to Access (not even sure if this is possible)?

 

-nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • 2 weeks later...
Posted

Ok here is my SQL,

 

strSQL = "SELECT DISTINCT PLCTest.*, employee.id, employee.name, employee_1.id, employee_1.name " & _

"FROM employee AS employee_1 INNER JOIN (employee INNER JOIN PLCTest ON " & _

"employee.id = PLCTest.Verantwoordelijke) ON employee_1.id = PLCTest.Tester " & _

"WHERE ((PLCTest.Projectnr = '" & strProjectNr & "') AND " & _

"(PLCTEST.Status = 'OK') AND " & _

"(PLCTEST.Boardnr = " & GarantyBoardnr & ")) " & _

"ORDER BY PLCTest.IO"

 

When I take out DISTINCT it works, with DISTINCT in my string it doesn't.

 

PLCTest is a Acces table and employee is a table on SQL-server

 

Boes

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...