473,325 Members | 2,805 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,325 software developers and data experts.

complicated SQL for MySQL

Hello

If I a user table and a item table has - in both a incremental value
is led (ID) - and I beside it in an order table all sales the user
lead, how I can all items to be indicated be able, which were not
bought of usern yet?

A beginning is:

SELECT DISTINCT * FROM items WHERE items.itemID EMERGENCY IN (SELECT
items.itemID FROM orders)

And as I bring the user purely?

Sea the following result:

user1 buys item1 and item2
user2 buys item3 and item1

result of the looked for SQL inquiry

item2 (not bought of user2)
item3 (not bought of user1)

The following solution brings to NULL as soon as more than one user
existed and both different things bought, together regards it however
everything bought (desire result quantity)

SELECT * FROM items i LEFT JOIN orders o ON (o.itemID = i.itemID) LEFT
JOIN users u ON (u.userID = o.userID) WHERE i.itemID IS NULL

possibly who has any idea?

Thanks

Rene
Jul 20 '05 #1
0 1232

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

Similar topics

4
by: lkrubner | last post by:
Pardon my lack of SQL knowledge. If I have two tables like this: weblogs{ id title mainContent } entries{ id
4
by: Aaron Baugher | last post by:
I have an OpenBSD 3.3 system running MySQL 3.23.55 from the ports tree. Everything started out at the default settings. This system holds a large vBulletin 2.2.9 forum database, and that's pretty...
4
by: mikey | last post by:
Hi all, I'm having great problems trying to install the latest MySQl RPM package onto my Red Hat Linux OS. There is already MySQL v 3.0 pre-installed with the RH Linux distribution disk but I...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
4
by: John Pedersen | last post by:
Hi, I have this table: CREATE TABLE `messages` ( `messageID` int(11) unsigned NOT NULL auto_increment, `threadID` int(11) unsigned, `fromUserName` varchar(50) default NULL, `toUserName`...
3
by: Chris | last post by:
Hello all- Fairly new to SQL and I need to issue a pretty complex query (complex being a relative term here :) ). To dumb down my example for display purposes, I have two tables in my schema...
4
by: SJ Mo2 | last post by:
I have several Access databases that I want to publish (or make available) through our web-pages. The problem...our web server is on a Linux-Apache machine while our Access db is obviously on a...
15
by: James | last post by:
Hello Everyone! I'm trying to design a database for a library that stocks a range of media. (see link) http://homepage.ntlworld.com/james.merrie/private/library.gif Each user can make many...
4
by: Matthew Crouch | last post by:
i suck so much that i don't even know if this is a JOIN or a subquery or who-knows what. Here's the idea: I want to select two things at the same time (form one table) average for columnX and...
0
by: norm10115 | last post by:
I have a single MySQL table named "monthly" that contains the following fields: Id, Name, Interface, Status, MonYear I want to query "Status" for the past 3 months, of each "Device" and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.