
January 16th, 2013, 11:01 AM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 1
Time spent in forums: 43 m 20 sec
Reputation Power: 0
|
|
|
SELECT with INNER JOIN to display only one record
I was wander whether someone could help me with a query problem I am having
I have the following tables with data
cart_session
q_id userid itemid quanity datetime_cart
126 1 10 1 2012-01-16 14:55:26
125 1 23 1 2012-01-16 14:56:26
shop_details
s_id sessid firstname surname email address ordertype orderstatus postcode datetime
20 1 Bob Smith bob@smith 145 Address Pay started xx21 x1 2012-01-16 14:56:26
When I execute the below query I get the following resuls
Quote: | SELECT cart_session.Q_id, cart_session.userid, cart_session.itemid, cart_session.quanity, cart_session.datetime_cart ,shop_detail.s_id, shop_detail.sessid, shop_detail.firstname, shop_detail.surname, shop_detail.email, shop_detail.address, shop_detail.ordertype, shop_detail.orderstatus, shop_detail.postcode ,shop_detail.datetime FROM shop_detail INNER JOIN cart_session ON cart_session.userid=shop_detail.sessid |
Result
q_id userid itemid quanity datetime_cart s_id sessid firstname surname email address ordertype postcode datetime
126 1 10 1 2012-01-16 14:55:26 20 1 Bob Smith bob@smith 145 Address Pay started xx21 x1 2012-01-16 14:56:26
125 1 23 1 2012-01-16 14:56:26 20 1 Bob Smith bob@smith 145 Address Pay started xx21 x1 2012-01-16 14:56:26
But I only would like to get one top record. Do you think you would be able to help me with my problem.
Kind Regards;
Arek
|