IBM developerWorks
           Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old July 11th, 2001, 10:44 PM
Scumgrief's Avatar
Scumgrief Scumgrief is offline
Metal-Freak
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Kuala Lumpur, Malaysia
Posts: 43 Scumgrief User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 45 sec
Reputation Power: 8
MySQL error

I have a few tables and two of them are called teachers and teach. Teachers contain info about the teachers and teach contain the subjects which the teachers teach. When I do a query:

select * from Teachers where teach.subjectID=BM1;

the result is this error:-

Unknown table 'teach' in where clause

what happened? can anyone enlighten me?

Scumgrief

Reply With Quote
  #2  
Old July 12th, 2001, 09:52 PM
phreq phreq is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: New Zealand
Posts: 167 phreq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 3 sec
Reputation Power: 8
It's the 'from' bit...

You need to name all the tables involved in the query in the 'from' bit. Like this:

select * from Teachers, teach where teach.subjectID=BM1;

Hope that helps,

Jen

Reply With Quote
  #3  
Old July 14th, 2001, 04:27 AM
Piper Piper is offline
To understand recursion, you have to understand recursion first!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: Germany
Posts: 174 Piper User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
You should use ...

the relating ids from both tables in the WHERE clause as well, ie.
... WHERE teachers.id = teach.id AND teach.subjectID=BM1;

btw: if the teach.subjectID is a character column you should consider smth. like that: ...WHERE ... AND teach.subjectID ='BM1'

Hope that helps

Quote:
Originally posted by phreq
You need to name all the tables involved in the query in the 'from' bit. Like this:

select * from Teachers, teach where teach.subjectID=BM1;

Hope that helps,

Jen
__________________
---BP-------------------------------------------
"Life is what happens, while you're makin' other plans..."

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > MySQL error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway