473,396 Members | 1,864 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,396 software developers and data experts.

Simply query of joined tables

Ike
I have a simple query of joined tables that is failing to give me any rows
of data (though, in checking by hand, it certainly should). Essentially, I
am trying to return all rows from `ups` that have `floattime` not equal
to it's default value of '0' (please not, in this db dates and times are
saved as varchars - so essentially I am comparing strings)

SELECT ups.date,associates.branch ,associates.username ,ups.time
,ups.floattime FROM ups ,associates WHERE
(ups.associatekey=associates.id) AND ups.date >='2005-12-05%' AND ups.date
<='2005-12-07%' AND ups.cxl <=0 AND ups.floattime <>'0'

The structure of the two tables is:

CREATE TABLE `ups` (
`id` int(11) NOT NULL auto_increment,
`date` varchar(16) default NULL,
`time` varchar(11) default NULL,
`associatekey` int(11) default NULL,
`floattime` varchar(11) NOT NULL default '0',
PRIMARY KEY (`id`)
)

CREATE TABLE `associates` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(16) NOT NULL default '',
`branch` varchar(30) default NULL,
)

My query returns an empty result set, which I have said is not right. Oddly,
if I eliminate the last phrase of the sql statement, "ups.floattime <>'0' "
it runs, returning all rows, but making the joins between the tables
correctly. Then, if I eliminate the need to join the tables (i.e. if I say I
dont want information about the associate) and distill my query down to
SELECT date,time,floattime FROM ups WHERE date >='2005-12-05%' AND
date <='2005-12-07%' AND floattime <>'0'

It runs correctly, returning the four correct rows.

2005-12-06 Tue 11:05:29 11:04:27
2005-12-07 Wed 13:59:14 13:58:23
2005-12-07 Wed 14:08:10 14:07:23
2005-12-07 Wed 14:13:30 14:12:33

So I am asking here, how can I construct this query, given the above table
structures, to return information about the associate as I have tried to do
in the initial query? What do I have wrong with that initial query that it
will not return the information I am looking for? TIA, Ike
Dec 8 '05 #1
1 1933
Ike wrote:
I have a simple query of joined tables that is failing to give me any rows
of data (though, in checking by hand, it certainly should). Essentially, I
am trying to return all rows from `ups` that have `floattime` not equal
to it's default value of '0' (please not, in this db dates and times are
saved as varchars - so essentially I am comparing strings)

SELECT ups.date,associates.branch ,associates.username ,ups.time
,ups.floattime FROM ups ,associates WHERE
(ups.associatekey=associates.id) AND ups.date >='2005-12-05%' AND ups.date
<='2005-12-07%' AND ups.cxl <=0 AND ups.floattime <>'0'

The structure of the two tables is:

CREATE TABLE `ups` (
`id` int(11) NOT NULL auto_increment,
`date` varchar(16) default NULL,
`time` varchar(11) default NULL,
`associatekey` int(11) default NULL,
`floattime` varchar(11) NOT NULL default '0',
PRIMARY KEY (`id`)
)

CREATE TABLE `associates` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(16) NOT NULL default '',
`branch` varchar(30) default NULL,
)

My query returns an empty result set, which I have said is not right. Oddly,
if I eliminate the last phrase of the sql statement, "ups.floattime <>'0' "
it runs, returning all rows, but making the joins between the tables
correctly. Then, if I eliminate the need to join the tables (i.e. if I say I
dont want information about the associate) and distill my query down to
SELECT date,time,floattime FROM ups WHERE date >='2005-12-05%' AND
date <='2005-12-07%' AND floattime <>'0'

It runs correctly, returning the four correct rows.

2005-12-06 Tue 11:05:29 11:04:27
2005-12-07 Wed 13:59:14 13:58:23
2005-12-07 Wed 14:08:10 14:07:23
2005-12-07 Wed 14:13:30 14:12:33

So I am asking here, how can I construct this query, given the above table
structures, to return information about the associate as I have tried to do
in the initial query? What do I have wrong with that initial query that it
will not return the information I am looking for? TIA, Ike

What is ups.cxl? You are using it in the WHERE clause but it
isn't in your CREATE TABLE statement.

Jerry
Dec 8 '05 #2

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

Similar topics

9
by: Ed_No_Spam_Please_Weber | last post by:
Hello All & Thanks in advance for your help! Background: 1) tblT_Documents is the primary parent transaction table that has 10 fields and about 250,000 rows 2) There are 9 child tables with...
2
by: sqlgoogle | last post by:
Hi I'm having update problem. Here is the senario I have to different db server (SQL Server) linked with each other In DB Server 1 I have 2 tables & In DB Server 2 I have 3 tables. I have...
2
by: allyn44 | last post by:
Hello--I have 2 tables (illness,event) that a need to query and create a recordset The key fields are personId and description (text field) in each table. I also have other needed fields in the...
4
by: John Baker | last post by:
Hi: I have two tables, a setup table (TblSetup) and a purchase order table (tblPO). When i construct a query with ONLY the tblPO shown, and a type in parameter for the PO number, I an update...
1
by: Michael | last post by:
I have a query that uses two joined tables. The query contains data. I would like to pull in a data drom another table but when I add that table to the query design and make the join,the existing...
1
by: Carl B Davis | last post by:
Help please!!! I am an intermediate access user that is getting my bottom kicked by what seems an easy problem to fix. I maintain an employee database at work. I have set up a query from two tables...
14
by: Tom | last post by:
Using AccessXP in 2000 mode. I have the following tables --- TblLocation LocationID PropertyID StateID CountyID CityID
5
by: listerofsmeg01 | last post by:
Hi, Pretty new to PHP and MySQL. I have a page on my site that displays a lot of information from various tables. Currently I have lots of small PHP wrapper functions around SQL queries to...
1
by: racquetballer | last post by:
I need to to an update query that involves three tables: table Dealer needs to be updated with data from table Personnel and table Title. Dealer is joined to Personnel where Dealer.Dealer_Code =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
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...

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.