473,668 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL statement help

28 New Member
i trying to read data from quite a few tables.. Now the statement works well except when i include the where e.equipmentLoca tionID = l.equipmentLoca tionID AND e.cabinetID = c.cabinetID AND e.equipmentOsID = osy.equipmentOs ID AND e.equipmentServ iceLevelID = s.equipmentServ iceLevelID AND e.equipmentType ID = eq.equipmentTyp eID . But i need to include since the output i want is not the ID but the field.
I am using PHP...


Expand|Select|Wrap|Line Numbers
  1. $query = "select e.equipmentName, e.equipmentSerTagNum,l.location,c.name , osy.osName , s.type, e.hardwareDescription,e.macAddress,e.rackNum, eq.type,e.hostServerName,e.updatedDate,e.warrantyStartDate, e.warrantyEndDate ,e.equipmentBrand,e.equipmentApplication
  2.         from equipmentInfo as e, equipmentLocation as l, cabinet as c, os as osy ,serviceLevelType as s, equipmentType as eq
  3.  
  4. where e.equipmentLocationID = l.equipmentLocationID AND e.cabinetID = c.cabinetID AND e.equipmentOsID= osy.equipmentOsID AND e.equipmentServiceLevelID = s.equipmentServiceLevelID AND e.equipmentTypeID = eq.equipmentTypeID 
  5.  
  6. And e.equipmentName like \"%$trimmed%\" or  e.equipmentSerTagNum like \"%$trimmed%\"  
  7.   order by e.equipmentName"; 
  8.  
  9.  
  10.  
Mar 18 '08 #1
7 1177
ronverdonk
4,258 Recognized Expert Specialist
Do you get an error, and which one, or is the SQL statement executed without taking the WHERE clause ? Do you have a [php]or die("error ".mysql_error() );[/php] to catch errors? If not surre show the PHP mysql_* command used.

Ronald
Mar 18 '08 #2
princelindie
28 New Member
Expand|Select|Wrap|Line Numbers
  1. connect();
  2.  
  3.  
  4. // Build SQL Query  
  5.  
  6. $query = "select e.equipmentName, e.equipmentSerTagNum,l.location,c.name , osy.osName , s.type, e.hardwareDescription,e.macAddress,e.rackNum, eq.type,e.hostServerName,e.updatedDate,e.warrantyStartDate, e.warrantyEndDate ,e.equipmentBrand,e.equipmentApplication
  7.         from equipmentInfo as e, equipmentLocation as l, cabinet as c, os as osy ,serviceLevelType as s, equipmentType as eq
  8.  
  9.         where e.equipmentLocationID = l.equipmentLocationID AND e.cabinetID = c.cabinetID AND e.equipmentOsID= osy.equipmentOsID AND e.equipmentServiceLevelID = s.equipmentServiceLevelID AND e.equipmentTypeID = eq.equipmentTypeID 
  10.  
  11.         AND e.equipmentName like \"%$trimmed%\" or  e.equipmentSerTagNum like \"%$trimmed%\"  
  12.   order by e.equipmentName" or die("error".mysql_error()); 
  13.  
  14.  
  15.  $numresults=mysql_query($query);
  16.  
  17.  
Mar 18 '08 #3
ronverdonk
4,258 Recognized Expert Specialist
So?? see my last post. Do you get an error or is the statement just executed without anything returning?

Ronald
Mar 18 '08 #4
princelindie
28 New Member
So?? see my last post. Do you get an error or is the statement just executed without anything returning?

Ronald
it executed without anything returning
Mar 18 '08 #5
ronverdonk
4,258 Recognized Expert Specialist
So the statement is correct and working. To me it looks like there is no database result to be returned from that statetement.

Ronald
Mar 18 '08 #6
princelindie
28 New Member
i getting results without the following statement.
Expand|Select|Wrap|Line Numbers
  1.  where e.equipmentLocationID = l.equipmentLocationID AND e.cabinetID = c.cabinetID AND e.equipmentOsID= osy.equipmentOsID AND e.equipmentServiceLevelID = s.equipmentServiceLevelID AND e.equipmentTypeID = eq.equipmentTypeID 
  2.  
but i need to include it for the outpuit i looking for..
whenever i include it returns nothing...
Mar 18 '08 #7
ronverdonk
4,258 Recognized Expert Specialist
Then NOTHING matches that where clause. The combination of these restrictions is not there.

When you are pertinent that there must be a result, then do some debugging.

Have you tried to issue the WHERE clause with fewer restrictions? Like starting with the first one and see what is returned. If anything is returned, gradually expand the where clause until it returns nothing?

Ronald
Mar 18 '08 #8

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

Similar topics

3
6223
by: Robert Mark Bram | last post by:
Hi All! I have the following two methods in an asp/jscript page - my problem is that without the update statement there is no error, but with the update statement I get the following error: Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80004005) Syntax error in UPDATE statement. /polyprint/dataEntry.asp, line 158
4
3268
by: James E Koehler | last post by:
I can't get the WHILE statement to work in MySQL. The version of MySQL that I am using is: Ver 12.16 Distrib 4.0.6-gamma, for Win95/Win98 (i32) running on Windows MX. Here is the relevant section from the manual: 20.1.9.7 WHILE Statement
2
2359
by: Little PussyCat | last post by:
Hello, I hope you can help me. We have a SQL Server 2000 database at work, (which works with a VB6 frontend) which grew to a considerable size, so one of my past colleagues sent me this truncate statement to use on the database. I ran it like this, and all appeared to be well, it shrank the database, Shortly afterwards, after I ran this I noticed something not quite right. for example, one of the tables we keep is a User_Admin table...
5
3501
by: WindAndWaves | last post by:
Hi Team The function below searches all the tables in a database. However, if subsearch = true then it searches all the objects listed in a recordset (which are all table names). I thought to be really clever and use : #if subsearch ... #else ..... #end if
11
2192
by: Scott C. Reynolds | last post by:
In VB6 you could do a SELECT CASE that would evaluate each case for truth and execute those statements, such as: SELECT CASE True case x > y: dosomestuff() case x = 5: dosomestuff() case y > x: dosomestuff()
10
2360
by: John Smith | last post by:
Can you do a Select Statement within a Select Statement? I want to build a query similar to queries built in Access which link to other queries but using only SQL Statements. Is it possible? If so, how do you do it? Thanx in adv.
6
2684
by: FayeC | last post by:
I really need help figuring this out. i have a db with mostly text fields but 2. The user_id field is an autonumber (key) and the user_newsletter is a number (1 and 0) field meaning 1 yes the person wants to receive a newsletter and 0 no, don't want to receive it. Now.....when trying to create an UPDATE statement I am running into problems writing the code for it. I had issues before with missing commas but now that the commas are there...
4
5602
by: Jack | last post by:
Hi, I have a asp page where part of the code is as follows. This builds up the sql statement partially. sql01 = "UPDATE EquipmentTbl SET " sql01 = sql01 & "SerialNumber = '" & request.form(strSerialNum) & "', " sql01 = sql01 & "Description = '" & request.form(strDesc) & "', " sql01 = sql01 & "Location = '" & request.form(strLoc) & "', "
7
2688
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about the goals -- the make statement is mostly syntactic sugar for:: class <name> <tuple>: __metaclass__ = <callable>
18
7960
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp defintion of "expression" and "statement"? What is the difference between an expression and a statement?
0
8459
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8374
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8575
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8653
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6206
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5677
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2784
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.