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 »

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: 6106
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Database query help

Post by AmigoJack »

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 problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
Locked

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