2

How i do this query using query builder:

SELECT code FROM client WHERE code
//                =(SELECT max(code) FROM client where code LIKE '" . $year . "%')";

i try this:

$row = Client::find(DB::table('client')->max('code'));

but return null

1 Answer 1

4

Try this: Client::where('code', 'LIKE', $year . '%')->max('code');

Sign up to request clarification or add additional context in comments.

1 Comment

@FabioSantos please, tag answer like a Best, if it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.