Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another Complex SQL Query Question

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi,

I've got a table containing data in this manner:

id | bon | content
1 | 10 | Excpt Storno
2 | 10 | Std Bar
3 | 11 | Norm Art 110
4 | 12 | Std Bar

Id is the index. "bon" contains the counter of a sales slip/check of a cash-register. Each row represents a row of the check. That way it is easy to search for one line.

But the user should able to search for more than one "content" *in the same* check, i.e. "In which check are both "Excpt Storno" AND "Std Bar"?" -> Only in check No. 10.

I tried to do an inner join, something like SELECT * FROM bon tab1, bon tab2 WHERE tab1.bon = tab2.bon AND tab1.content LIKE 'Std Bar%' OR tab1.content LIKE 'Excpt Zeilenstorno%'

But this results in nothing useable.

Is anyone here able to help me?

TIA,

Falk
 
I've got it!

SELECT DISTINCT tab1.bon
FROM bon tab1, bon tab2
WHERE tab1.bon = tab2.bon AND tab1.content LIKE 'Std Bar%' AND
tab2.content LIKE 'Excpt Zeilenstorno%'
ORDER BY tab1.bon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top