Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi all.
I got a proble with SQL query I want to use.
I got the following 2 Tables. SKU and SKUXLOCExample.
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 = 0This 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.

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

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 > 0This doesn't work. Please Help.

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.

![]() |
BATCH: Choice.e...
|
Telenet via batch file
|

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