SQL select for Car Plates

I want to extract a list of car plates which have passed through a certain point. I am asked to list the plates which are not domestic.
The domestic plate order is like one of these:
99 X 9999
99 X 99999
99 XX 999
99 XX 9999
99 XXX 99
99 XXX 999

Hi Ugurh,

You can search your table like this:

SELECT * FROM Plates WHERE Plate LIKE '%[0-9][0-9][A-Z][0-9][0-9][0-9][0-9]%'

Wildcard to match characters - SQL Server (Transact-SQL) | Microsoft Learn

Sorry but that does not work. I have come to find this ;

SELECT * FROM customers WHERE PlakaNo REGEXP '[1]+$'

which gives the domestic plates now but I need to find out the phrase that give the opposite of this now. I mean the plates which are not domestic.

  1. A-Za-z0-9 ↩︎

Looks like you use MySQL?

SELECT * FROM customers WHERE PlakaNo NOT REGEXP '+$'

MySQL :: MySQL 8.0 Reference Manual :: 12.8.2 Regular Expressions

This brings not only domestic plates but internationals too like AA293AA, can we simplify it to bring only internationals ?

I solved it.

select * from customers where PlakaNO not regexp '[1]{2}[A-Za-z]{1,3}[0-9]{2,5}$'

  1. 0-9 ↩︎