Naija Ryders

Go Back   Naija Ryders > Main > Techie Forum
Connect with Facebook
Register Blogs FAQ Members List Guitar Hero Calendar Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old 03-11-2008, 05:56 PM   #1 (permalink)
The 4 Eyed Monk.
 
maestro's Avatar
 
Join Date: Oct 2005
Location: Abuja, Nigeria
Posts: 41,510
Points: 100,113,253.22
Bank: 176.10
Total Points: 100,113,429.32
Donate
Blog Entries: 1
Rep Power: 2470000000 maestro has disabled reputation



Default MySql help

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*
__________________
maestro is offline   Reply With Quote
Old 03-11-2008, 06:26 PM   #2 (permalink)
Registered User
 
omonija's Avatar
 
Join Date: Jun 2005
Location: somewhere shaaa...
Posts: 2,551
Points: 7,200.00
Bank: 8,952,368.10
Total Points: 8,959,568.10
Donate
Rep Power: 0 omonija omonija omonija omonija omonija omonija omonija omonija omonija omonija omonija
Default

shouldn't this be in the techie forum?
omonija is offline   Reply With Quote
Old 03-11-2008, 06:32 PM   #3 (permalink)
No Angel
 
bored's Avatar
 
Join Date: Dec 2005
Location: California Dreaming
Posts: 19,405
Points: 409,540.48
Bank: 7,536,896,672.27
Total Points: 7,537,306,212.75
Donate
Rep Power: 21474888 bored is a legendbored is a legendbored is a legendbored is a legendbored is a legendbored is a legendbored is a legendbored is a legendbored is a legendbored is a legendbored is a legend


Default

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:
Originally posted by jerseygirl
Where oh where could my little bored be?
Could she actually be hiding from me?
I've searched this board, high and low
written witty comebacks....but she's a no show

I know she is addicted...of this fact I'm sure
Or could it be that she don't love me no more
Come back and bring some more sunshine to my dreary day
with the colorful and mischievous things you say

I'll patiently wait for you to return to me...
please make it soon...I fear for what might be
My boredom has driven me to rhyme
Stop lurking and post, so we can have a swell time
bored is offline   Reply With Quote
Old 03-11-2008, 06:34 PM   #4 (permalink)
No Angel
 
bored's Avatar
 
Join Date: Dec 2005
Location: California Dreaming
Posts: 19,405
Points: 409,540.48
Bank: 7,536,896,672.27
Total Points: 7,537,306,212.75
Donate
Rep Power: 21474888 bored is a legendbored is a legendbored is a legendbored is a legendbored is a legendbored is a legendbored is a legendbored is a legendbored is a legendbored is a legendbored is a legend


Default

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:
Originally posted by jerseygirl
Where oh where could my little bored be?
Could she actually be hiding from me?
I've searched this board, high and low
written witty comebacks....but she's a no show

I know she is addicted...of this fact I'm sure
Or could it be that she don't love me no more
Come back and bring some more sunshine to my dreary day
with the colorful and mischievous things you say

I'll patiently wait for you to return to me...
please make it soon...I fear for what might be
My boredom has driven me to rhyme
Stop lurking and post, so we can have a swell time
bored is offline   Reply With Quote
Old 03-11-2008, 06:36 PM   #5 (permalink)
Registered User
 
Arokoyo's Avatar
 
Join Date: Oct 2006
Location: Bermuda Triangle
Posts: 7,582
Points: 17,815.31
Bank: 54,612,497.56
Total Points: 54,630,312.87
Donate
Rep Power: 21474863 Arokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legend



Default

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"
Arokoyo is offline   Reply With Quote
Old 03-11-2008, 06:36 PM   #6 (permalink)
*Confirmed Sexist*
 
dibia's Avatar
 
Join Date: Nov 2002
Location: Off through the window, experiencing life
Posts: 27,235
Points: 5,500.00
Bank: 15,511,645,322.73
Total Points: 15,511,650,822.73
Donate
Rep Power: 21474910 dibia is a legenddibia is a legenddibia is a legenddibia is a legenddibia is a legenddibia is a legenddibia is a legenddibia is a legenddibia is a legenddibia is a legenddibia is a legend
Default

...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.
dibia is offline   Reply With Quote
Old 03-11-2008, 06:36 PM   #7 (permalink)
Registered User
 
Arokoyo's Avatar
 
Join Date: Oct 2006
Location: Bermuda Triangle
Posts: 7,582
Points: 17,815.31
Bank: 54,612,497.56
Total Points: 54,630,312.87
Donate
Rep Power: 21474863 Arokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legend



Default

ok didn't see that bored
__________________
Hal Turner:
"...i am perfectly willing to use force and violence against my enemies"
Arokoyo is offline   Reply With Quote
Old 03-11-2008, 06:37 PM   #8 (permalink)
*Confirmed Sexist*
 
dibia's Avatar
 
Join Date: Nov 2002
Location: Off through the window, experiencing life
Posts: 27,235
Points: 5,500.00
Bank: 15,511,645,322.73
Total Points: 15,511,650,822.73
Donate
Rep Power: 21474910 dibia is a legenddibia is a legenddibia is a legenddibia is a legenddibia is a legenddibia is a legenddibia is a legenddibia is a legenddibia is a legenddibia is a legenddibia is a legend
Default

Quote:
Originally Posted by omonija
shouldn't this be in the techie forum?

...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.
dibia is offline   Reply With Quote
Old 03-11-2008, 06:39 PM   #9 (permalink)
~Nicest Winsh in Town~
 
virgoluv's Avatar
 
Join Date: Jun 2002
Location: Texas, Y'all
Posts: 38,319
Points: 148,565.95
Bank: 353,842,547.54
Total Points: 353,991,113.49
Donate
Rep Power: 21474933 virgoluv is a legendvirgoluv is a legendvirgoluv is a legendvirgoluv is a legendvirgoluv is a legendvirgoluv is a legendvirgoluv is a legendvirgoluv is a legendvirgoluv is a legendvirgoluv is a legendvirgoluv is a legend



Default

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/
virgoluv is offline   Reply With Quote
Old 03-11-2008, 06:59 PM   #10 (permalink)
Registered User
 
djmightymike's Avatar
 
Join Date: Dec 2006
Location: Festac Town
Posts: 8,638
Points: 1,278,100,513.38
Bank: 0.02
Total Points: 1,278,100,513.40
Donate
Rep Power: 21474865 djmightymike is a legenddjmightymike is a legenddjmightymike is a legenddjmightymike is a legenddjmightymike is a legenddjmightymike is a legenddjmightymike is a legenddjmightymike is a legenddjmightymike is a legenddjmightymike is a legenddjmightymike is a legend



Default

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
djmightymike is offline   Reply With Quote
Old 03-11-2008, 07:03 PM   #11 (permalink)
The 4 Eyed Monk.
 
maestro's Avatar
 
Join Date: Oct 2005
Location: Abuja, Nigeria
Posts: 41,510
Points: 100,113,253.22
Bank: 176.10
Total Points: 100,113,429.32
Donate
Blog Entries: 1
Rep Power: 2470000000 maestro has disabled reputation



Default

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'"
:frustated
__________________
maestro is offline   Reply With Quote
Old 03-11-2008, 07:18 PM   #12 (permalink)
Registered User
 
djmightymike's Avatar
 
Join Date: Dec 2006
Location: Festac Town
Posts: 8,638
Points: 1,278,100,513.38
Bank: 0.02
Total Points: 1,278,100,513.40
Donate
Rep Power: 21474865 djmightymike is a legenddjmightymike is a legenddjmightymike is a legenddjmightymike is a legenddjmightymike is a legenddjmightymike is a legenddjmightymike is a legenddjmightymike is a legenddjmightymike is a legenddjmightymike is a legenddjmightymike is a legend



Default

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
djmightymike is offline   Reply With Quote
Old 03-11-2008, 07:30 PM   #13 (permalink)
The 4 Eyed Monk.
 
maestro's Avatar
 
Join Date: Oct 2005
Location: Abuja, Nigeria
Posts: 41,510
Points: 100,113,253.22
Bank: 176.10
Total Points: 100,113,429.32
Donate
Blog Entries: 1
Rep Power: 2470000000 maestro has disabled reputation



Default

Quote:
Originally Posted by djmightymike
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
...thank U..I just saw that error. Make I fix am letter.
__________________
maestro is offline   Reply With Quote
Old 03-11-2008, 07:34 PM   #14 (permalink)
Registered User
 
Arokoyo's Avatar
 
Join Date: Oct 2006
Location: Bermuda Triangle
Posts: 7,582
Points: 17,815.31
Bank: 54,612,497.56
Total Points: 54,630,312.87
Donate
Rep Power: 21474863 Arokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legend



Default

Quote:
Originally Posted by maestro
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'"
:frustated
1. why are you using a left join?
2. you want to select admin.username and admin.password ending with "s". you use the keyword "like" not "=".
PHP Code:
SELECT Admin.UsernameAdmin.PasswordSuperAdmin.UsernameSuperAdmin.Password
FROM Admin INNER JOIN SuperAdmin ON Admin
.adminId SuperAdmin.adminId
WHERE 
(((Admin.UsernameLike "%s")) OR (((Admin.PasswordLike "%s")); 
or

PHP Code:
SELECT Admin.UsernameAdmin.PasswordSuperAdmin.UsernameSuperAdmin.Password
FROM SuperAdmin
LEFT JOIN Admin ON SuperAdmin
.adminId Admin.adminId
WHERE 
(((Admin.UsernameLike "%s")) OR (((Admin.PasswordLike "%s")); 
__________________
Hal Turner:
"...i am perfectly willing to use force and violence against my enemies"
Arokoyo is offline   Reply With Quote
Old 03-11-2008, 07:38 PM   #15 (permalink)
Registered User
 
Arokoyo's Avatar
 
Join Date: Oct 2006
Location: Bermuda Triangle
Posts: 7,582
Points: 17,815.31
Bank: 54,612,497.56
Total Points: 54,630,312.87
Donate
Rep Power: 21474863 Arokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legendArokoyo is a legend



Default

Quote:
Originally Posted by maestro
...thank U..I just saw that error. Make I fix am letter.


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"
Arokoyo is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Points Per Thread View: 0
Points Per Thread: 0
Points Per Reply: 0
Forum Jump


All times are GMT +2. The time now is 11:30 PM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
NaijaRyders