WN

WN (https://www.wn.se/forum/index.php)
-   Serversidans teknologier (https://www.wn.se/forum/forumdisplay.php?f=4)
-   -   sql inner join problem (https://www.wn.se/forum/showthread.php?t=32734)

filipbjerne 2008-10-22 19:47

vad kan felet vara??

Fick felmeddelande:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[MySQL][ODBC 3.51 Driver][mysqld-5.0.37-community-nt]Unknown column 'tu.userID' in 'on clause'



Kod:

SELECT

tu.userID, tu.userName, tu.userInvitedBy, tu.userPicture, tu.userAddressCity, tue.userEducationSchool, tue.userEducationSchoolAlignment, tuw.userWorkEmployer, tuw.userWorkPosition

FROM

tableUser tu,
tableUserEducation tue,
tableUserWork tuw

INNER JOIN
tableUserEducation tue2 ON tu.userID = tue2.userEducationToID

INNER JOIN
tableUserWork tuw2 ON tu.userID = tuw2.userWorkToID

WHERE

tu.userName LIKE '%" & functionInjection(Request.Querystring("searchField")) & "%' AND
tu.userAddressCity LIKE '%" & functionInjection(Request.Querystring("usercity")) & "%' AND
tu.userAddressCountry LIKE '%" & functionInjection(Request.Querystring("usercountry")) & "%' AND
tu.userWebsite LIKE '%" & functionInjection(Request.Querystring("userWebsite")) & "%' AND
tue.userEducationSchool LIKE '%" & functionInjection(Request.Querystring("userEducationSchool")) & "%' AND
tue.userEducationSchoolAlignment LIKE '%" & functionInjection(Request.Querystring("userEducationSchoolAlignment")) & "%' AND
tuw.userWorkEmployer LIKE '%" & functionInjection(Request.Querystring("userWorkEmployer")) & "%' AND
tuw.userWorkPosition LIKE '%" & functionInjection(Request.Querystring("userWorkPosition")) & "%' " & stringSQL & " AND
tu.userAccept = 1

GROUP BY

tu.userID

ORDER BY

tu.userName ASC,
tu.userOnline ASC,
tu.userLoginDate DESC


Lundmark 2008-10-22 23:06

Måste du inte ha
Citat:


tableUser AS tu,
tableUserEducation AS tue,
tableUserWork AS tuw

För i tabellen tableUser har du väll ett fält som heter userID?

guran 2008-10-22 23:14

Det borde fungera om du skriver om enligt följande:

FROM

tableUser tu

filipbjerne 2008-10-23 13:31

med eller utan "AS" i FROM så fungerar det inte....


och ja jag har ju userID i den tabellen så det är så konstigt!

Devworks 2008-10-23 21:47

AS spelar ingen roll. Testa koppla tabellerna istället, t.ex:

SELECT t1.myfield, t2.theirfield FROM table1 t1, table2 t2 WHERE t1.id = t2.id

Vill du att jag kikar på satsen så som du konstruerat den så gör en schema-dump på tabellerna så att man kan testa.


Alla tider är GMT +2. Klockan är nu 16:10.

Programvara från: vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Svensk översättning av: Anders Pettersson