私は2つのテーブルを持っています:
tickets
ticket_id, int(11), NO, PRI, , auto_increment
order_num, varchar(45), NO, , ,
user_id, int(11), YES, , ,
event_id, int(11), YES, , ,
number_of_tickets, varchar(4), YES, , ,
order_placed, timestamp, NO, , CURRENT_TIMESTAMP,
payment_recd, enum('Yes','No'), YES, , No,
payment_time, timestamp, YES, , ,
events
event_id, int(11), NO, PRI, , auto_increment
venue_id, int(11), YES, , ,
event_date, date, YES, , ,
event_time, time, YES, , ,
event_price, decimal(4,2), YES, , ,
event_capacity, int(11), YES, , ,
dateadded, timestamp, NO, , CURRENT_TIMESTAMP,
ユーザーが購入したチケットをリストし、イベントの日付で注文する必要がありますが、次のようにしようとしているのは正しくソートされていません
select tickets.order_num as ordnum, tickets.event_id as tickid, tickets.number_of_tickets as numtix
from tickets, events
where ((tickets.user_id = '1') and (tickets.payment_recd = 'Yes'))
group by tickets.order_num
order by events.event_date asc
何か案は?