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

Use the order by with limit 1.

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

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";

No worries :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.