473,545 Members | 1,471 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unusual Query Help Request

cov
I have a query where I'm attempting to pull data from 3 different
tables using php and mysql. I had hoped to have a unique identifier
to help ensure referential integrity but it appears that unique number
won't always be a possibility so I won't bank on it at all.

I have two like fields in these two tables 'area' and 'equipment' and
though there is a possibility of having two different pieces of
equipment within two areas called by the same thing, the possibility
of having two pieces of equipment called the same thing if I can link
to that 'area' column is impossible, hence my unique id

Below is what my existing code looks like that works but doesn't link
the 'area' column of a table to the 'equipment' column. Didn't notice
a problem until several entries to the db. Now I can see that I must
link the two columns within the individual tables to form a unique
identifier for those particular table rows within the three tables.

------------------------------------------
<?php
require_once('g eneric_connect. php');
$DBname = "Equipment" ;
$area = $_POST['area'];

mysql_connect($ DBhost, $DBuser, $DBpass) or die("Unable to connect to
host $DBhost");
mysql_select_db ($DBname) or die("Unable to select database $DBname");

$query = "SELECT conveyors.equip name, conveyors.equip no,
conveyors.mcc, conveyors.gb, conveyors.lube, conveyors.gbsiz e,
conveyors.brgty pe, conveyors.brgqt y, motors.hp, motors.frame,
motors.amps, motors.rpm, equipcontacts.e quipmanu,
equipcontacts.s model, equipcontacts.s serial, equipcontacts.v endphone
FROM conveyors, motors, equipcontacts
WHERE conveyors.equip name = motors.equipnam e and
conveyors.equip name = equipcontacts.e quipname ";
if ($area != "All") $query .= "and (conveyors.area ='$area' or
motors.area='$a rea' or equipcontacts.a rea='$area')";
$result = mysql_query($qu ery);
----------------------------------

I would have hoped that linking the two columns within each table may
be as simple as:
WHERE conveyors.area. equipname = motors.area.equ ipname and
conveyors.area. equipname = equipcontacts.a rea.equipname ";

but no such luck. My tables are 'conveyors', 'motors' and
'equipcontacts' .

thanks for any replies.
cov
Nov 9 '07 #1
18 2281
cov wrote:
I have a query where I'm attempting to pull data from 3 different
tables using php and mysql. I had hoped to have a unique identifier
to help ensure referential integrity but it appears that unique number
won't always be a possibility so I won't bank on it at all.

I have two like fields in these two tables 'area' and 'equipment' and
though there is a possibility of having two different pieces of
equipment within two areas called by the same thing, the possibility
of having two pieces of equipment called the same thing if I can link
to that 'area' column is impossible, hence my unique id

Below is what my existing code looks like that works but doesn't link
the 'area' column of a table to the 'equipment' column. Didn't notice
a problem until several entries to the db. Now I can see that I must
link the two columns within the individual tables to form a unique
identifier for those particular table rows within the three tables.

------------------------------------------
<?php
require_once('g eneric_connect. php');
$DBname = "Equipment" ;
$area = $_POST['area'];

mysql_connect($ DBhost, $DBuser, $DBpass) or die("Unable to connect to
host $DBhost");
mysql_select_db ($DBname) or die("Unable to select database $DBname");

$query = "SELECT conveyors.equip name, conveyors.equip no,
conveyors.mcc, conveyors.gb, conveyors.lube, conveyors.gbsiz e,
conveyors.brgty pe, conveyors.brgqt y, motors.hp, motors.frame,
motors.amps, motors.rpm, equipcontacts.e quipmanu,
equipcontacts.s model, equipcontacts.s serial, equipcontacts.v endphone
FROM conveyors, motors, equipcontacts
WHERE conveyors.equip name = motors.equipnam e and
conveyors.equip name = equipcontacts.e quipname ";
if ($area != "All") $query .= "and (conveyors.area ='$area' or
motors.area='$a rea' or equipcontacts.a rea='$area')";
$result = mysql_query($qu ery);
----------------------------------

I would have hoped that linking the two columns within each table may
be as simple as:
WHERE conveyors.area. equipname = motors.area.equ ipname and
conveyors.area. equipname = equipcontacts.a rea.equipname ";

but no such luck. My tables are 'conveyors', 'motors' and
'equipcontacts' .

thanks for any replies.
cov
Table definitions would help...

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Nov 9 '07 #2
cov
On Fri, 09 Nov 2007 16:31:09 -0500, Jerry Stuckle
<js*******@attg lobal.netwrote:
>Table definitions would help...
Table type is innoDB, character set is utf-u unicode, and fields are
varchar. Each table the same where 'type' is concerned and 'area' is
always the column next to 'equipment'. Table's were originated using
default settings with phpMyAdmin 2.6.2 thanks
Nov 10 '07 #3
cov wrote:
On Fri, 09 Nov 2007 16:31:09 -0500, Jerry Stuckle
<js*******@attg lobal.netwrote:
>Table definitions would help...

Table type is innoDB, character set is utf-u unicode, and fields are
varchar. Each table the same where 'type' is concerned and 'area' is
always the column next to 'equipment'. Table's were originated using
default settings with phpMyAdmin 2.6.2 thanks
He meant what are the column names in the tables... along with the
datatype of each column (describe <tablename)
Nov 10 '07 #4
cov
On Fri, 09 Nov 2007 22:20:38 -0600, Michael Austin
<no******@thist ime.infwrote:

>He meant what are the column names in the tables... along with the
datatype of each column (describe <tablename)

Ahh, thanks... :-)

table names are 'conveyors', 'motors', 'equipcontacts'
Nov 10 '07 #5
cov wrote:
On Fri, 09 Nov 2007 16:31:09 -0500, Jerry Stuckle
<js*******@attg lobal.netwrote:
>Table definitions would help...

Table type is innoDB, character set is utf-u unicode, and fields are
varchar. Each table the same where 'type' is concerned and 'area' is
always the column next to 'equipment'. Table's were originated using
default settings with phpMyAdmin 2.6.2 thanks
Which isn't your table definitions, and tells me absolutely nothing
about your problem.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Nov 10 '07 #6
cov wrote:
On Fri, 09 Nov 2007 22:20:38 -0600, Michael Austin
<no******@thist ime.infwrote:

>He meant what are the column names in the tables... along with the
datatype of each column (describe <tablename)


Ahh, thanks... :-)

table names are 'conveyors', 'motors', 'equipcontacts'
Which still tells me nothing...

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Nov 10 '07 #7
cov
On Sat, 10 Nov 2007 00:01:21 -0500, Jerry Stuckle
<js*******@attg lobal.netwrote:
>cov wrote:
>On Fri, 09 Nov 2007 16:31:09 -0500, Jerry Stuckle
<js*******@att global.netwrote :
>>Table definitions would help...

Table type is innoDB, character set is utf-u unicode, and fields are
varchar. Each table the same where 'type' is concerned and 'area' is
always the column next to 'equipment'. Table's were originated using
default settings with phpMyAdmin 2.6.2 thanks

Which isn't your table definitions, and tells me absolutely nothing
about your problem.
Perhaps you could help. How might I find the table definitions?
Nov 10 '07 #8
On Sat, 10 Nov 2007 07:43:13 +0100, cov <co************ @yahoo.comwrote :
On Sat, 10 Nov 2007 00:01:21 -0500, Jerry Stuckle
<js*******@attg lobal.netwrote:
>cov wrote:
>>On Fri, 09 Nov 2007 16:31:09 -0500, Jerry Stuckle
<js*******@at tglobal.netwrot e:

Table definitions would help...

Table type is innoDB, character set is utf-u unicode, and fields are
varchar. Each table the same where 'type' is concerned and 'area' is
always the column next to 'equipment'. Table's were originated using
default settings with phpMyAdmin 2.6.2 thanks

Which isn't your table definitions, and tells me absolutely nothing
about your problem.

Perhaps you could help. How might I find the table definitions?
DESCRIBE tablename;
--
Rik Wasmus
Nov 10 '07 #9
cov
On Sat, 10 Nov 2007 18:13:17 +0100, "Rik Wasmus"
<lu************ @hotmail.comwro te:

>DESCRIBE tablename;
Each table has an id field that is an INT - this field auto-increments
and is the primary key field for each table. All others are varchar
25 limit w/no other key set. Zero decimals and allow null not set.
thanks
Nov 10 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
2477
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules" for when and how to use single quotes and double quotes in ASP? thanks! ---------------------- SQL = SQL & "WHERE '" &...
3
5373
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says there is a sample file called Ixtrasp.asp, but I could not find it in my system although I installed indexing service. I followed the steps in MSDN...
3
1685
by: Farooq Khan | last post by:
why does Response.Write in a method of code-beind class when called from inpage code (i.e in <%---%>), after creating object of that class, fails when called while it works perfectly ok while calling the same method same way except for creating object instead directly calling the method? i get this when trying to do that:- ...
9
23692
by: Mark | last post by:
I've run a few simple tests looking at how query string encoding/decoding gets handled in asp.net, and it seems like the situation is even messier than it was in asp... Can't say I think much of the "improvements", but maybe someone here can point me in the right direction... First, it looks like asp.net will automatically read and recognize...
1
1327
by: Dunc | last post by:
I have a site with a number of pages that make use of an ID and an anchor in the querystring (e.g. www.mysite.com/news.aspx?NewsTypeID=7#NewsID_49). For some reason, when it's visited by a search engine, it's replacing the hash with a %23 and asp.net is only seeing one parameter, which results in a number format error when trying to read...
1
1947
by: TF | last post by:
This group came through for me last time so here we go again. My page shows paint colors, brand name, product code, etc in a gridview with the background matching the paint color. Several links on the page are used to call itself with querystring values for brand, thinner, finish, etc. The page must show all colors if the querystring is...
3
2544
by: pbd22 | last post by:
Hi. I need some help with structuring my query strings. I have a form with a search bar and some links. Each link is a search type (such as "community"). The HREF for the link's anchor looks like the following: <a href="?searchtype=2">Community</a>
10
1411
by: sheldonlg | last post by:
I got an unusual request. One customer wants a password/access made available to a user that is valid for only, say, ten minutes. I know that I can enforce this by having a revalidation of the password every time the user changes a page. This, though, seems like a a lot of overhead in having to make a db call every time a page is changed. ...
24
3068
by: MU | last post by:
Hello I have some code that sets a dropdownlist control with a parameter from the querystring. However, when the querystring is empty, I get an error. Here is my code: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then
0
7465
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7805
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7416
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7752
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5325
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4944
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
701
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.