![]() |
|
|
#1 (permalink) |
|
The 4 Eyed Monk.
![]() |
I want to join select 2 fields from 2 different tables, and the usual error that one of the fields is ambigous keeps coming up...I have used JOIN, no dice...any help will do. this is my mysql version *MySQL client version: 5.0.37*
__________________
|
|
|
|
|
|
#3 (permalink) | |
|
No Angel
![]() Join Date: Dec 2005
Location: California Dreaming
Rep Power: 21474888
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
C&P your query.
__________________
All views stated here by the character "Bored" are purely fictional in no way represent the views of the poster. Any resemblance between my views and all views stated here is non-deterministic. "Those who wish to love and sing always find a song" :A Swedish Proverb. Si Hoc Legere Scis Nimium Eruditionis Habes Quote:
|
|
|
|
|
|
|
#4 (permalink) | |
|
No Angel
![]() Join Date: Dec 2005
Location: California Dreaming
Rep Power: 21474888
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
it sounds like one of the fields is present in both tables. Did you specify which field is from which table as per table1.field1 and table2.field2 ?
__________________
All views stated here by the character "Bored" are purely fictional in no way represent the views of the poster. Any resemblance between my views and all views stated here is non-deterministic. "Those who wish to love and sing always find a song" :A Swedish Proverb. Si Hoc Legere Scis Nimium Eruditionis Habes Quote:
|
|
|
|
|
|
|
#5 (permalink) |
|
Registered User
![]() Join Date: Oct 2006
Location: Bermuda Triangle
Rep Power: 21474863
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
you have the precede the fieldname with the name of the table.
tablename.fieldname it's ambigious cos the field probably exists in both tables, so its not sure which table you are referencing. make sure that all your fields are done that way!
__________________
Hal Turner: "...i am perfectly willing to use force and violence against my enemies"
|
|
|
|
|
|
#6 (permalink) |
|
*Confirmed Sexist*
![]() ![]() Join Date: Nov 2002
Location: Off through the window, experiencing life
Rep Power: 21474910
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
...what bored said. The ambiguous error usually means you need to specify which table the troublesome column is in.
__________________
The Devil made me do it the first time. The second time, I done it on my own. - Billy Joe Shaver www.nighttofly.com - support our naija film makers. |
|
|
|
|
|
#8 (permalink) | |
|
*Confirmed Sexist*
![]() ![]() Join Date: Nov 2002
Location: Off through the window, experiencing life
Rep Power: 21474910
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Quote:
...oh yeah, i almost forgot.... @this post.
__________________
The Devil made me do it the first time. The second time, I done it on my own. - Billy Joe Shaver www.nighttofly.com - support our naija film makers. |
|
|
|
|
|
|
#9 (permalink) |
|
~Nicest Winsh in Town~
![]() Join Date: Jun 2002
Location: Texas, Y'all
Rep Power: 21474933
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
hmm geektalk...that was almost hot pipuz.
__________________
The biggest decision a woman can make in her life is not who to marry but who should be the father of her children..You can't undo it There's nothing more scary than watching ignorance in action. http://www.tayne-ment.blogspot.com/ |
|
|
|
|
|
#10 (permalink) |
|
Registered User
![]() Join Date: Dec 2006
Location: Festac Town
Rep Power: 21474865
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Classic relational DB problem.
consider two tables ![]() and lets say you'd like to return lastnames of employees for which thier department id exists in the department table. SELECT Employee.LastName FROM Employee JOIN Department ON Employee.DepartmentID = Department.DepartmentID pm me the table structures and the set you'd like to return if u still getting errors
__________________
The Lord is my Shepherd -Psalms 23 http://djmightymike.net http://truspotradio.com http://myspace.com/naijadjs http://myspace.com/dj_mightymike |
|
|
|
|
|
#11 (permalink) |
|
The 4 Eyed Monk.
![]() |
This is my problem, i have named my fields table.column name, but i am still have some SQL errors.
What i actually want to achieve is allowing 2 people from 2 usergroups to be able to log into a page i.e peeps from an admin table and peeps from a superadmin table this is my sql Code:
"SELECT admin.Username, admin.Password, superadmin.Username, superadmin.Password FROM Admin LEFT JOIN superadmin USING (admin_id) WHERE admin.Username = '%s' AND admin.Password= '%s'"
__________________
|
|
|
|
|
|
#12 (permalink) |
|
Registered User
![]() Join Date: Dec 2006
Location: Festac Town
Rep Power: 21474865
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
The first line in the query will fail becasue you're selecting superadmin columns from Admin table.
secondly, i think this problem can be easily solved with better db design. consider having a "privilege" key that will exist in both tables and then that way you can select a set using that "privilege" column as key. brb..let me go complie this build i'm doin and i'll try fiind a solution for what u wanna do. My queries are based on SQL server but most likely it wil pass on mySQL
__________________
The Lord is my Shepherd -Psalms 23 http://djmightymike.net http://truspotradio.com http://myspace.com/naijadjs http://myspace.com/dj_mightymike |
|
|
|
|
|
#13 (permalink) | |
|
The 4 Eyed Monk.
![]() |
Quote:
...thank U..I just saw that error. Make I fix am letter.
__________________
|
|
|
|
|
|
|
#14 (permalink) | |
|
Registered User
![]() Join Date: Oct 2006
Location: Bermuda Triangle
Rep Power: 21474863
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Quote:
2. you want to select admin.username and admin.password ending with "s". you use the keyword "like" not "=". PHP Code:
PHP Code:
__________________
Hal Turner: "...i am perfectly willing to use force and violence against my enemies"
|
|
|
|
|
|
|
#15 (permalink) | |
|
Registered User
![]() Join Date: Oct 2006
Location: Bermuda Triangle
Rep Power: 21474863
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Quote:
![]() okor mi, tell me adminid is not common in both tables. na wa oh anyways, im thinking of you stalk you later ![]()
__________________
Hal Turner: "...i am perfectly willing to use force and violence against my enemies"
|
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|