[PHP-DB] RE: Urgent JOIN help needed
Why you are getting multiple results is because a JOIN attempts to find all the possible combinations in the output. (It's called a Cartesian product, not that you care at this very moment.) Also, when doing joins, it's a bad idea to do a select * since you will have two fields with the same value (the field on which you are joining. Also, it's best to use the . notation for table reference so that you have no abiguity. This is one picky note, but not all dbs are as flexible as MySQL: when you are specifying the ON clause, your LEFT table should always be the table to the LEFT of the equal sign. MySQL does not care, but it's good practice. I would change it to: $sql = SELECT vendorprices.*, fooditems.Description FROM vendorprices LEFT JOIN fooditems on (vendorprices.VendorNumber = fooditems.CategoryNumber) WHERE (vendorprices.CategoryNumber = '$VendorID'). You are on the right track with LEFT Join, that is precisely what is needed for the output you want. -Original Message- From: Chris Payne [mailto:[EMAIL PROTECTED] Sent: Fri 7/30/2004 8:25 PM To: [EMAIL PROTECTED] Cc: Subject:Urgent JOIN help needed Hi there everyone, I'm new to JOINS and have followed some info in the MySQL manual but I'm at a loss, using the code I'll paste below, I get each result 4 times and I am confused as to why? Basically I'm trying to display ALL fields from the vendorprices table, and grab just the Description column from the fooditems table, the factor which joins them both is the string $VendorID which in the vendorprices table is VendorNumber and in the fooditems table is CategoryNumber. $sql = SELECT * FROM vendorprices LEFT JOIN fooditems on (vendorprices.VendorNumber = fooditems.CategoryNumber AND fooditems.CategoryNumber = '$VendorID') WHERE vendorprices.VendorNumber='$VendorID' AND fooditems.CategoryNumber='$VendorID'; Can anyone see where I'm going wrong? This is driving me nuts and I need to figure it out urgently. Thank you for your help. Regards Chris
[PHP-DB] Re: urgent guys
You cannot use javascript variables in php, nor php variables in javascript, unless you write the variable to the page (for php - javascript) or post to a new page with querystring or form (javascript - php). php - javascript: script language=JavaScript var jsVariable = ?= $phpVariable ?; /script javascript - php: script language=JavaScript // this is probably wrong javascript syntax, but you get the idea location.href = thing.php?q=first+onep=second+one; /script Adam i know it has nothing to do with php but i'm stuck:) i have this url: http://localhost/auction/seller/additems.php?category=Bookssubcategory=Fiction and in javascript when i say for example alert(category) it gives me undefineddoesn't javascript see variables passed with the url??? Rehab M.Shouman
[PHP-DB] Re: Urgent!!!
and who looks the query with substr the date so i get only the year? Type the exact query you make. -- Best regards, George Nicolae IT Manager ___ X-Playin - Professional Web Design www.x-playin.f2s.com Thomas Omega Henning [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I forgot to type in something if i substr the date so i get only the year from it then is it possible? George Nicolae [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... you can't make this query because type mismatches. -- Best regards, George Nicolae IT Manager ___ X-Playin - Professional Web Design www.x-playin.f2s.com Thomas Omega Henning [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello, Is it possible to order the table somethin like this 'select * from intrat order by idatum+iszam DESC; ' where idatum is date and iszam is int thanks Thomas omega Henning -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: Urgent!!!
Sorry but I don't have the query done yet . But maybe later I will have it done but I don't know how to use the substr command in mySQL . If you tell me how to use it I will post it on the forum. Thomas omega Henning George Nicolae [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... and who looks the query with substr the date so i get only the year? Type the exact query you make. -- Best regards, George Nicolae IT Manager ___ X-Playin - Professional Web Design www.x-playin.f2s.com Thomas Omega Henning [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I forgot to type in something if i substr the date so i get only the year from it then is it possible? George Nicolae [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... you can't make this query because type mismatches. -- Best regards, George Nicolae IT Manager ___ X-Playin - Professional Web Design www.x-playin.f2s.com Thomas Omega Henning [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello, Is it possible to order the table somethin like this 'select * from intrat order by idatum+iszam DESC; ' where idatum is date and iszam is int thanks Thomas omega Henning -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: Urgent!!!
I have some idea about your problem but to solve I need some information. 1. you have a datatime, data, timestamp,time or year column? if you have a data type column with -mm-dd format you can use the following query select substring_index(date_record,-,1)+id from test date_record is a date column id is an integer column -- Best regards, George Nicolae IT Manager ___ X-Playin - Professional Web Design www.x-playin.f2s.com Thomas Omega Henning [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Sorry but I don't have the query done yet . But maybe later I will have it done but I don't know how to use the substr command in mySQL . If you tell me how to use it I will post it on the forum. Thomas omega Henning George Nicolae [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... and who looks the query with substr the date so i get only the year? Type the exact query you make. -- Best regards, George Nicolae IT Manager ___ X-Playin - Professional Web Design www.x-playin.f2s.com Thomas Omega Henning [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I forgot to type in something if i substr the date so i get only the year from it then is it possible? George Nicolae [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... you can't make this query because type mismatches. -- Best regards, George Nicolae IT Manager ___ X-Playin - Professional Web Design www.x-playin.f2s.com Thomas Omega Henning [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello, Is it possible to order the table somethin like this 'select * from intrat order by idatum+iszam DESC; ' where idatum is date and iszam is int thanks Thomas omega Henning -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: Urgent!!!
select substring_index(date_record,-,1)+id as sum from test order by sum -- Best regards, George Nicolae IT Manager ___ X-Playin - Professional Web Design www.x-playin.f2s.com Thomas Omega Henning [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... My date is like -MM-DD as to the select you posted that selects only those to i need it ordered by the sum of these to fields Thomas omega Henning George Nicolae [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I have some idea about your problem but to solve I need some information. 1. you have a datatime, data, timestamp,time or year column? if you have a data type column with -mm-dd format you can use the following query select substring_index(date_record,-,1)+id from test date_record is a date column id is an integer column -- Best regards, George Nicolae IT Manager ___ X-Playin - Professional Web Design www.x-playin.f2s.com Thomas Omega Henning [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Sorry but I don't have the query done yet . But maybe later I will have it done but I don't know how to use the substr command in mySQL . If you tell me how to use it I will post it on the forum. Thomas omega Henning George Nicolae [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... and who looks the query with substr the date so i get only the year? Type the exact query you make. -- Best regards, George Nicolae IT Manager ___ X-Playin - Professional Web Design www.x-playin.f2s.com Thomas Omega Henning [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I forgot to type in something if i substr the date so i get only the year from it then is it possible? George Nicolae [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... you can't make this query because type mismatches. -- Best regards, George Nicolae IT Manager ___ X-Playin - Professional Web Design www.x-playin.f2s.com Thomas Omega Henning [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello, Is it possible to order the table somethin like this 'select * from intrat order by idatum+iszam DESC; ' where idatum is date and iszam is int thanks Thomas omega Henning -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: Urgent! Store Data In A Text File!
To retrieve data from a text file, I'm using: $fp= file(textfile.txt,r); foreach($fp as $line) echo - $line -; Jerry Arik Ashepa [EMAIL PROTECTED] wrote: Can someone please tell me how can I add and retrive data from a text file I know it has something to do with Spliting...??? But I dont know the code... Arik -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: Urgent!!!
you can't make this query because type mismatches. -- Best regards, George Nicolae IT Manager ___ X-Playin - Professional Web Design www.x-playin.f2s.com Thomas Omega Henning [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello, Is it possible to order the table somethin like this 'select * from intrat order by idatum+iszam DESC; ' where idatum is date and iszam is int thanks Thomas omega Henning -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: Urgent!!!
I forgot to type in something if i substr the date so i get only the year from it then is it possible? George Nicolae [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... you can't make this query because type mismatches. -- Best regards, George Nicolae IT Manager ___ X-Playin - Professional Web Design www.x-playin.f2s.com Thomas Omega Henning [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello, Is it possible to order the table somethin like this 'select * from intrat order by idatum+iszam DESC; ' where idatum is date and iszam is int thanks Thomas omega Henning -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]