0

Hello:

I have a mysql table which has following rows:

id (unique and auto increment)
platenumber
customerid
servicearea
date

I want to create a sql statement which essentially performs the following task: Pull from table_name the last inserted row where the customerid='mb6537'.

There could be more than one row containing this customerid, I simply want to pull the last inserted.

Any one has a thought on this!
Mossa

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by phpology
0

Use the order by with limit 1.

select from tbl where customer = 'x' order by idenitity_column desc limit 1

0

Use the order by with limit 1.

select from tbl where customer = 'x' order by idenitity_column desc limit 1

Much oblige! that did it... final sql statement:

$get_swork = "select servicearea, date from services where clientID = '$clientID' order by id desc limit 1";

Edited by mbarandao: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.