Computing.Net > Forums > Programming > SQL Query

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

SQL Query

Reply to Message Icon

Name: Deon
Date: June 2, 2008 at 07:09:37 Pacific
OS: XP SP2
CPU/Ram: 2Ghz 15.Gb
Product: Dell
Comment:

Hi all.
I got a proble with SQL query I want to use.
I got the following 2 Tables. SKU and SKUXLOC

Example.

SKU TABLE

SKU |Description |Supp
-----------------------
1234 |Book1 |Supp1
4567 |Book2 |Supp2
7890 |Book3 |Supp3

SKUXLOC TABLE

SKU |Location |QTY |LOCATION
-----------------------
1234 |PICK |1 |BD-55
1234 |Bulk |98 |BF-88
7890 |Bulk |55 |BD-78
7890 |Pick |0 |BF-42
7890 |Pick |2 |BF-98


I want my Query to show me in table SKU the SKU that the Detail in SKUXLOC for that Items as follow.
Location is BULK and Qty > 0 and location is Pick ans QTY = 0 ( MUST HAVE BOTH VALUES )

I have got the following.
Select SKU from SKU where SKUXLOC.LOCATION = "BULK" and SKUXLOC.QTY >0 AND SKUXLOC = "PICK" and SKUXLOC.QTY = 0

This returns Nothing Where it should return Item 7890. If I am Correct my script tries to read everthing from one line. I think I should use Parent Child Table Query but don't know how.



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: June 2, 2008 at 09:25:02 Pacific
Reply:

It's not a good idea to name two columns the same name even if your database allows it. i.e. Location -> LOCATION

Anyway, you need to do a join:


select b.sku from sku a
join skuxloc b
on a.sku = b.sku
where b.Location = "Pick" and b.qty = 0


0

Response Number 2
Name: Deon
Date: June 3, 2008 at 02:08:41 Pacific
Reply:

I tried this but it gives me no results.

Sory my bad. the first one is a LocationType

select b.sku from sku a
join skuxloc b
on a.sku = b.sku
where b.Locationtype = 'Case' and b.qty > 0

This doesn't work. Please Help.


0

Response Number 3
Name: nails
Date: June 3, 2008 at 16:07:41 Pacific
Reply:

I take it no data returns - not that a syntax error exists. I don't want to elaborate on the obvious, but 'Case' doesn't exist in your original data. Are you sure it exists in your production database.

Also, not every database is set up to be case insensitive. i.e. 'Case' isn't the same as 'CASE'.

I don't know what to tell you. This join is about the most simple join you can execute.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


BATCH: Choice.e... Telenet via batch file



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: SQL Query

Access sql query mystery!! www.computing.net/answers/programming/access-sql-query-mystery/12793.html

SQL Query www.computing.net/answers/programming/sql-query/11590.html

Need SQL query help. www.computing.net/answers/programming/need-sql-query-help/13097.html