473,434 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

Need Help: Mysql Database Query;

Hi i am new to this, first time joined a forum. Anyway my problem is i have two tables:

table1: establishment(estNo mediumint, estName varchar, other details..) Primary key=estNo;

table2: foodType(food varchar(), estNo mediumint) Foreign key=estNo, Primary Key=(food, estNo);

user inputs: inputEstName for establishment and inputFood for foodType;

im trying to set up a query via php that does the following:
SELECT all establishment details from establisment
ONLY IF
establishment.estName=inputEstName;
foodType.estNo=establishment.estNo && foodType.food = inputFood;
(where I get the estNo when a record has been found for the estName input)

the query in php that i have got so far looks like this:
$select= "select estNo, estName, details from establishment
where estName=" . $inputEstName .
"AND establishment.estNo=foodType.estNo
AND foodType.food=" . $ inputFood;

Help would be much appreciated,

Eric
When you are in a forum the very first time: READ THE POSTING GUIDELINES!!, especially the part on enclsosing code with php, html ot code tags!! - Ronald
Nov 10 '06 #1
5 1808
cassbiz
202 100+
Expand|Select|Wrap|Line Numbers
  1. $select= "select estNo, estName, details from establishment
  2. where estName=" . $inputEstName .
  3. "AND establishment.estNo=foodType.estNo
  4. AND foodType.food=" . $ inputFood;
You can try to enter your select string like this. I have found it to work for me.

Expand|Select|Wrap|Line Numbers
  1. $select= ("SELECT estNo, estName, details FROM establishment
  2. WHERE estName='$inputEstName' AND establishment.estNo=foodType.estNo
  3. AND foodType.food='$inputFood'");
  4.  
Nov 10 '06 #2
in the where query part:
Expand|Select|Wrap|Line Numbers
  1. WHERE estName=$inputEstName AND establishment.estNo=foodType.estNo
  2. AND foodType.food=$inputFood";
  3.  
I get an error reporting "unknown column foodType.estNo in where clause".

I presume i need to define somewhere a connection to the foodType table to access the foodType.estNo field...

Eric
Nov 10 '06 #3
cassbiz
202 100+
in the where query part:
Expand|Select|Wrap|Line Numbers
  1. WHERE estName=$inputEstName AND establishment.estNo=foodType.estNo
  2. AND foodType.food=$inputFood";
  3.  
I get an error reporting "unknown column foodType.estNo in where clause".

I presume i need to define somewhere a connection to the foodType table to access the foodType.estNo field...

Eric
Try this code

Expand|Select|Wrap|Line Numbers
  1. $select= ("SELECT establishment.estNo, foodType.estNo, establishment.details FROM establishment,
  2. foodType WHERE establishment.estName='$inputEstName' AND establishment.estNo=foodType.estNo
  3. AND foodType.food='$inputFood'");
  4.  
Nov 10 '06 #4
cassbiz
202 100+
I got the following code from

builder.com
Nov 10 '06 #5
cheers that worked perfectly
Nov 10 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Erich Trowbridge | last post by:
Has anybody seen this tool? It is awesome. check out http://vw.vermeer.org/ . It's a php front end for large-scale syslog deployments. It makes managing syslog in large networks a snap. The idea...
3
by: James | last post by:
Please help - getting very desperate! Sun, 12 October 2003 05:39 I have PHPDEV 4.2.3 from Firepages.com.au as the upgrade to 4.3.0 did not work. I also had an abortive download from PHP.NET as...
6
by: Dal | last post by:
Help! I'm trying to get a login script to work. I get this error message MySQL Login Error: You have an error in your SQL syntax near ''jvsd0001_customers` WHERE cust_name='testuser' AND...
2
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
5
by: lkrubner | last post by:
I have a webserver through Rackspace. I create a domain. I create an FTP user. I upload some files. I create a database called testOfSetupScript and then I create a database user named setup. I...
1
by: Cern | last post by:
Is it somebody out there who has made a migration from an Oracle server to an MySQL server?? The scenario is as simply: I've got a Oracle 8 server with a database with content that I want to...
2
by: Jeffrey D Moncrieff | last post by:
I am trying to create a data base for colleting date for my research project. I have run in to a couple of problems and I need it fast ASAP I need it to be able to add data and edit them and view...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
2
by: dmstn | last post by:
Hey! I've got a little problem. I have to make a web site for a university essay. I curently have to create a search engine. Users can enter a hotel name in a search bar and results have to appear in...
3
by: fantomel | last post by:
<?php /* Create the mysql class_exists */ class mysql {
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.