The below Postgres SQL query is returning all records available in the table.
Can someone give explanation for this? .
Also please let me know what * represents in case of postgres regular expression.
Employee table contains :
name
Chennai
Delhi
Hydrabad
NewYark
ABC
select * from employee where name ~ 'Z*'
The
*quantifier means zero or more. Since every name contains at least zeroZcharacters, every row is returned.You don’t need to use a regex to find strings starting with a character, you can just use
LIKE:If you want names starting with Z using a regex, try this:
If you want names containing at least one Z, try one of these: