Database query help

Discussion forum for MOD Writers regarding MOD Development.
Locked
popgammy
Registered User
Posts: 1
Joined: Thu Oct 01, 2015 7:17 pm

Database query help

Post by popgammy » Thu Oct 01, 2015 7:25 pm

Hello

Can someone give me an example a query I would need in order to accomplish the following, I would like it in a single query if possible.

I have 2 tables: itemsforsale and itemsbought

When the user visits the page I want only to display products from itemsforsale that the user has not purchased already, doesn't exist in itemsbought.

So something like

Code: Select all

SELECT items FROM itemsforsale WHERE item-with-same-item DOES NOT EXIST in itemsbought WHERE user_id = user and item_id = itemsforsaleid
So basically just looping through the tables and only outputting itemforsale that don't exist in the itemsbought tablet for that specific user. :?

User avatar
AmigoJack
Registered User
Posts: 4999
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Database query help

Post by AmigoJack » Mon Oct 05, 2015 8:20 am

While the answer is quite simple I don't see what this has to do with phpBB at all. Also you didn't tell your DBMS - there might be a specific non ANSI-SQL slang that might be needed. And on top describe your tables. Not with words, of course - with CREATE TABLE...
The worst thing about censorship is ███████████

Locked

Return to “[3.0.x] MOD Writers Discussion”

Who is online

Users browsing this forum: No registered users and 13 guests

cron