PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

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:
  #16  
Old October 3rd, 2012, 01:16 PM
jonnyfreak jonnyfreak is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 67 jonnyfreak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 54 m 55 sec
Reputation Power: 1
Quote:
Originally Posted by gw1500se
Nope. Use poochieProd.ProdID


yes i tried that

<?php
$query2 = sprintf("
SELECT DISTINCT
stock.stockID, size.Size
FROM
poochieProd AS prod
LEFT JOIN poochieStock AS stock ON Prod.ID = stock.ID
LEFT JOIN poochieSizes AS size ON stock.SizeID = size.SizeID
WHERE
poochieProd.ProdID = '%s' AND stock.stock > 0
ORDER BY
size.SizeID ASC", GetSQLValueString($var3_Recordset1, "int"));
$results2 = mysql_query($query2);
while($row2 = mysql_fetch_array($results2)){
?>

and got the following error?

Error in query: SELECT DISTINCT stock.stockID, size.Size FROM poochieProd AS prod LEFT JOIN poochieStock AS stock ON Prod.ID = stock.ID LEFT JOIN poochieSizes AS size ON stock.SizeID = size.SizeID WHERE poochieProd.ProdID = '-1' AND stock.stock > 0 ORDER BY size.SizeID ASC. Unknown table 'poochieProd' in where clause

Reply With Quote
  #17  
Old October 3rd, 2012, 01:17 PM
SecurityDavid SecurityDavid is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 170 SecurityDavid User rank is Second Lieutenant (5000 - 10000 Reputation Level)SecurityDavid User rank is Second Lieutenant (5000 - 10000 Reputation Level)SecurityDavid User rank is Second Lieutenant (5000 - 10000 Reputation Level)SecurityDavid User rank is Second Lieutenant (5000 - 10000 Reputation Level)SecurityDavid User rank is Second Lieutenant (5000 - 10000 Reputation Level)SecurityDavid User rank is Second Lieutenant (5000 - 10000 Reputation Level)SecurityDavid User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 2 h 34 m 47 sec
Reputation Power: 53
Quote:
Originally Posted by jonnyfreak
i thought the poochieProd AS prod

was telling the next part to see poochieProd as prod so

WHERE prod.ProdID would see this?
That is correct, but the table "Prod" doesn't exist because you declared the table as "prod". It's case sensitive so you have to keep it in lowercase throughout the string.

Reply With Quote
  #18  
Old October 3rd, 2012, 01:21 PM
jonnyfreak jonnyfreak is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 67 jonnyfreak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 54 m 55 sec
Reputation Power: 1
Quote:
Originally Posted by SecurityDavid
That is correct, but the table "Prod" doesn't exist because you declared the table as "prod". It's case sensitive so you have to keep it in lowercase throughout the string.


i added the poochieProd.ProdID

and it returned

Unknown table 'poochieProd' in where clause

Reply With Quote
  #19  
Old October 3rd, 2012, 01:31 PM
gw1500se gw1500se is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,886 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 2 Weeks 3 Days 8 h 22 m 27 sec
Reputation Power: 581
Post the output from 'show tables' on that database.
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.

Reply With Quote
  #20  
Old October 3rd, 2012, 01:34 PM
jonnyfreak jonnyfreak is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 67 jonnyfreak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 54 m 55 sec
Reputation Power: 1
Quote:
Originally Posted by gw1500se
Post the output from 'show tables' on that database.



sorry how is that done?

thanks

Reply With Quote
  #21  
Old October 3rd, 2012, 01:40 PM
gw1500se gw1500se is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,886 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 2 Weeks 3 Days 8 h 22 m 27 sec
Reputation Power: 581
The easiest way is to use the mysql command then type:
use <database name>;
show tables;

Reply With Quote
  #22  
Old October 3rd, 2012, 01:52 PM
jonnyfreak jonnyfreak is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 67 jonnyfreak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 54 m 55 sec
Reputation Power: 1
Quote:
Originally Posted by gw1500se
The easiest way is to use the mysql command then type:
use <database name>;
show tables;


just trying how to figure out how to do this

Reply With Quote
  #23  
Old October 3rd, 2012, 01:57 PM
gw1500se gw1500se is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,886 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 2 Weeks 3 Days 8 h 22 m 27 sec
Reputation Power: 581
Are you on Windows or *NIX?

Reply With Quote
  #24  
Old October 3rd, 2012, 01:58 PM
jonnyfreak jonnyfreak is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 67 jonnyfreak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 54 m 55 sec
Reputation Power: 1
Quote:
Originally Posted by jonnyfreak
just trying how to figure out how to do this



can i do that from phpMyAdmin?

Reply With Quote
  #25  
Old October 3rd, 2012, 02:04 PM
jonnyfreak jonnyfreak is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 67 jonnyfreak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 54 m 55 sec
Reputation Power: 1
Quote:
Originally Posted by gw1500se
Are you on Windows or *NIX?


windows

Reply With Quote
  #26  
Old October 3rd, 2012, 02:11 PM
gw1500se gw1500se is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,886 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 2 Weeks 3 Days 8 h 22 m 27 sec
Reputation Power: 581
Yes you can do that from PHPAdmin.

Reply With Quote
  #27  
Old October 3rd, 2012, 02:18 PM
jonnyfreak jonnyfreak is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 67 jonnyfreak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 54 m 55 sec
Reputation Power: 1
Quote:
Originally Posted by gw1500se
Yes you can do that from PHPAdmin.


i opened up the SQL box

Run SQL query

and typed

use <dbpoochie>;
show tables;

but it gave me

There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem

ERROR: Unknown Punctuation String @ 14
STR: >;
SQL: use <dbpoochie>;use <dbpoochie>;use <dbpoochie>;

SQL query:

use <dbpoochie>;

MySQL said:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<dbpoochie>' at line 1

Reply With Quote
  #28  
Old October 3rd, 2012, 03:37 PM
jonnyfreak jonnyfreak is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 67 jonnyfreak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 54 m 55 sec
Reputation Power: 1
i have included all the values of the tables if that helps

Table name: poochieCat
CatID - int(11) - auto_increment
name - varchar(200)
image - varchar(200)

Table name: poochieProd
ProdID - int(11) - auto_increment
Prodname - varchar(200)
ProdDesc - text
CatID - varchar(80)



Table name: poochieSizes
SizeID - int(11) - auto_increment
Size - varchar(200)

Table name: poochieStock

stockID - int(11) - auto_increment
ProdID - varchar(80)
sizeID - varchar(80)
stock - varchar(30)
sold - varchar(10)


its that ok?

Reply With Quote
  #29  
Old October 3rd, 2012, 04:09 PM
SecurityDavid SecurityDavid is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 170 SecurityDavid User rank is Second Lieutenant (5000 - 10000 Reputation Level)SecurityDavid User rank is Second Lieutenant (5000 - 10000 Reputation Level)SecurityDavid User rank is Second Lieutenant (5000 - 10000 Reputation Level)SecurityDavid User rank is Second Lieutenant (5000 - 10000 Reputation Level)SecurityDavid User rank is Second Lieutenant (5000 - 10000 Reputation Level)SecurityDavid User rank is Second Lieutenant (5000 - 10000 Reputation Level)SecurityDavid User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 2 h 34 m 47 sec
Reputation Power: 53
Quote:
Originally Posted by jonnyfreak
i added the poochieProd.ProdID

and it returned

Unknown table 'poochieProd' in where clause
That's not what I said. Your statement declared the table "poochieProd AS prod" but then in your first join, you called your table "Prod" with a capital "P". If you declare your table as "prod" all in lower case, you need to call your table in all lower case every time, you can't change the case of your table name in the string. Also, once you've declared it as "prod" I believe you have to call it by the name you have declared; you can't go back to the real table name once you've declared it as something different. You're also referencing two different id fields (prod.ID and prod.ProdID) for the poochieProd table and your last post only indicated one. So, based on the last query string you posted, keeping the case the same would look like this.
PHP Code:
 $query2 sprintf("
        SELECT DISTINCT stock.stockID, size.Size
        FROM poochieProd AS prod
        LEFT JOIN poochieStock AS stock ON prod.ProdID = stock.ID
        LEFT JOIN poochieSizes AS size ON stock.SizeID = size.SizeID
        WHERE prod.ProdID = '%s' AND stock.stock > 0
        ORDER BY size.SizeID ASC"
GetSQLValueString($var3_Recordset1"int")); 

Reply With Quote
  #30  
Old October 3rd, 2012, 04:16 PM
jonnyfreak jonnyfreak is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 67 jonnyfreak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 54 m 55 sec
Reputation Power: 1
Quote:
Originally Posted by SecurityDavid
That's not what I said. Your statement declared the table "poochieProd AS prod" but then in your first join, you called your table "Prod" with a capital "P". If you declare your table as "prod" all in lower case, you need to call your table in all lower case every time, you can't change the case of your table name in the string. Also, once you've declared it as "prod" I believe you have to call it by the name you have declared; you can't go back to the real table name once you've declared it as something different. You're also referencing two different id fields (prod.ID and prod.ProdID) for the poochieProd table and your last post only indicated one. So, based on the last query string you posted, keeping the case the same would look like this.
PHP Code:
 $query2 sprintf("
        SELECT DISTINCT stock.stockID, size.Size
        FROM poochieProd AS prod
        LEFT JOIN poochieStock AS stock ON prod.ProdID = stock.ID
        LEFT JOIN poochieSizes AS size ON stock.SizeID = size.SizeID
        WHERE prod.ProdID = '%s' AND stock.stock > 0
        ORDER BY size.SizeID ASC"
GetSQLValueString($var3_Recordset1"int")); 


ok thanks i have changed that and it is now giving me another error

Error in query: SELECT DISTINCT stock.stockID, size.Size FROM poochieProd AS prod LEFT JOIN poochieStock AS stock ON prod.ProdID = stock.ID LEFT JOIN poochieSizes AS size ON stock.SizeID = size.SizeID WHERE prod.ProdID = '-1' AND stock.stock > 0 ORDER BY size.SizeID ASC. Unknown column 'stock.ID' in 'on clause'

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP-General - Cant get a select list working with joined table. HELP

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap