Jump to content

Find unpaid items -logic-


ericsante

Recommended Posts

I am building an auction administration site, I want to check the auction site for all the closed auctions for the user and compare this against the paid auction table and then display the items that need to be paid for.

I have the SQL query to find the closed auctions, however I am having problems doing the compare against the paid auctions table.

Thanks in advance.
Link to comment
Share on other sites

TABLE `winners` (
`id` int(11) NOT NULL auto_increment,
`auction` int(32) NOT NULL default '0',
`seller` int(32) NOT NULL default '0',
`winner` int(32) NOT NULL default '0',
`bid` double NOT NULL default '0',
`closingdate` timestamp(14) NOT NULL,
`fee` double NOT NULL default '0',
KEY `id` (`id`)
) TYPE=MyISAM;

TABLE `auctions` (
`id` int(32) NOT NULL auto_increment,
`user` int(32) default NULL,
`title` tinytext,
`starts` varchar(14) default NULL,
`description` text,
`pict_url` tinytext,
`category` int(11) default NULL,
`minimum_bid` double(16,4) default NULL,
`reserve_price` double(16,4) default NULL,
`buy_now` double(16,4) default NULL,
`auction_type` char(1) default NULL,
`duration` varchar(7) default NULL,
`increment` double(8,4) NOT NULL default '0.0000',
`location` varchar(30) default NULL,
`location_zip` varchar(10) default NULL,
`shipping` char(1) default NULL,
`payment` tinytext,
`international` char(1) default NULL,
`ends` varchar(14) default NULL,
`current_bid` double(16,4) default NULL,
`closed` char(2) default NULL,
`photo_uploaded` char(1) default NULL,
`quantity` int(11) default NULL,
`suspended` int(1) default '0',
`private` enum('y','n') NOT NULL default 'n',
`relist` int(11) NOT NULL default '0',
`relisted` int(11) NOT NULL default '0',
`num_bids` int(11) NOT NULL default '0',
`sold` enum('y','n','s') NOT NULL default 'n',
`shipping_terms` tinytext NOT NULL,
`bn_only` enum('y','n') NOT NULL default 'n',
`adultonly` enum('y','n') NOT NULL default 'n',
PRIMARY KEY (`id`),
KEY `id` (`id`)
) TYPE=MyISAM ;

TABLE `checkout_order` (
`auction` varchar(6) NOT NULL default '',
`user` int(32) NOT NULL default '0',
`firstname` varchar(40) NOT NULL default '',
`lastname` varchar(40) NOT NULL default '',
`address` varchar(40) NOT NULL default '',
`city` varchar(40) NOT NULL default '',
`state` varchar(40) NOT NULL default '',
`zip` varchar(40) NOT NULL default '',
`country` varchar(40) NOT NULL default '',
`phone` varchar(40) NOT NULL default '',
`email` varchar(40) NOT NULL default '',
`shipping_firstname` varchar(40) NOT NULL default '',
`shipping_lastname` varchar(40) NOT NULL default '',
`shipping_address` varchar(40) NOT NULL default '',
`shipping_city` varchar(40) NOT NULL default '',
`shipping_state` varchar(40) NOT NULL default '',
`shipping_zip` varchar(40) NOT NULL default '',
`shipping_country` varchar(40) NOT NULL default '',
`amount` varchar(10) NOT NULL default '',
`credits` varchar(10) NOT NULL default '',
`ipaddr` varchar(15) NOT NULL default '',
`processed` char(1) NOT NULL default '0',
PRIMARY KEY (`auction`)
) TYPE=MyISAM;

The query I have been using is

SELECT a.auction, a.winner, b.id, b.title, b.current_bid, c.auction
FROM winners a, auctions b, checkout_order c
WHERE a.auction = b.id
AND (
b.closed =1
OR b.closed = -1
)
AND b.suspended =0
AND a.winner =17609
AND a.auction != c.auction
LIMIT 0 , 30

----

in the auctions table I have the following records:

id | title | current_bid
1000 | something | 1.00
1001 | something | 1.00
1002 | something | 1.00
1003 | something | 1.00


in the winners I have the following records:

auction | winner| bid
1000 | 17609 | 1.00
1001 | 17609 | 1.00
1002 | 17609 | 1.00
1003 | 17610 | 1.00

in the checkout_orders I have the following records:

auction | user
1002 | 17609
1003 | 17610

so I would expect to see only the records 1000, 1001. However I get 1000,1001,1000,1000
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.