Reputation: 989
let's say I have a table called transaction and it looks like this
ID Price
--- -----------
706 117.94
707 151.60
708 185.29
719 117.94
711 195.85
If Price column's type were varchar, then I could select entries by part of Price values.
For example, if I did:
select * from transaction where Price like '%51%'
and I would get
707 151.60
However the Price column's type is numeric. How can I select entries by part of a numeric value?
Upvotes: 0
Views: 198
Reputation: 3179
MySQL
SQL Server
Oracle
SQLite
Everyone of them supports LIKE
on numbers.
It appears to be PostgreSQL you are using. With PostgreSQL we actually need to change datatype:
SELECT * FROM transaction1 WHERE CAST(Price AS text) LIKE '%51%';
Upvotes: 3