7 Einträge, 1 Seite |
Select ebay_id from Artikel LEFT JOIN gebote ON (Artikel.ID = gebote.artikel_id)
1
2
3
4
5
6
7
WHERE (SELECT count( * )
FROM gebote
WHERE user_id =1
AND high_bid =1
GROUP BY category, user_id
) <3
Limit 1 Order by Rand()
select coalesce (NULL, NULL, 'hallo welt')
olruebe01+2009-02-25 13:36:33--[...]
Soweit so gut. Das ganze klappt tatsächlich, solange ich weniger als 3 Artikel beboten habe. Habe ich jedoch in der TAbelle gebote KEINEN Eintrag, weil ich bisher noch kein Gebot auf ein Autradio abgegeben habe, findet der Subselect nichts und bedingung <3 ist nicht erfüllt :-(
[...]
Quote[...]
Not Exists hat mich auch nicht nach vorn gebracht.
[...]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
SELECT
items.title,
items.subtitle,
items.ebay_id AS item_id,
items.actual_price AS actual_price,
items.max_bid,
items.image_url,
user_settings.category,
user_settings.minbid,
user_settings.maxbid,
user_settings.item_condition,
user_settings.max_items_to_buy
FROM `users`
LEFT JOIN user_settings ON ( users.ID = user_settings.user_id)
LEFT JOIN items ON ( items.primary_category = user_settings.category)
LEFT JOIN placed_bids ON (placed_bids.user_id = users.ID)
WHERE
users.ebay_name ='".$GET_ARRAY["user_id"]."'
AND
(
user_settings.minbid >= items.actual_price
OR user_settings.minbid < 1
)
AND
(
user_settings.maxbid <= items.actual_price
OR user_settings.maxbid <1
)
AND
user_settings.category = items.primary_category
AND
items.item_closed=0
AND
items.actual_price < items.max_bid
AND
item_ends + INTERVAL 1 HOUR > NOW( )
Group by placed_bids.category,placed_bids.user_id
having (SELECT count(*) from placed_bids WHERE
user_id = users.ID AND high_bid =1
and category = items.primary_category group by category) < user_settings.max_items_to_buy
ORDER BY RAND()
LIMIT 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
SELECT
items.title,
items.subtitle,
items.ebay_id AS item_id,
items.actual_price AS actual_price,
items.max_bid,
items.image_url,
user_settings.category,
user_settings.minbid,
user_settings.maxbid,
user_settings.item_condition,
user_settings.max_items_to_buy
FROM `users`
LEFT JOIN user_settings ON ( users.ID = user_settings.user_id)
LEFT JOIN items ON ( items.primary_category = user_settings.category)
LEFT JOIN placed_bids ON (placed_bids.user_id = users.ID AND user_settings.category = placed_bids.category AND placed_bids.ebay_id = items.ebay_id)
WHERE
users.ebay_name ='".$GET_ARRAY["user_id"]."'
AND
(
user_settings.minbid >= items.actual_price
OR user_settings.minbid < 1
)
AND
(
user_settings.maxbid <= items.actual_price
OR user_settings.maxbid <1
)
AND
user_settings.category = items.primary_category
AND
items.item_closed=0
AND
items.actual_price < items.max_bid
AND
item_ends + INTERVAL 1 HOUR > NOW( )
having (SELECT count(*) from placed_bids WHERE
user_id = users.ID AND high_bid =1
and category = items.primary_category group by category) < user_settings.max_items_to_buy
ORDER BY RAND()
LIMIT 1
7 Einträge, 1 Seite |