How do you update the record in the first 2 letters as in the case below.
TABLE tblBuku
This is the condition
Some Code :
UPDATE tblBuku SET Jenis = 'Informatika' WHERE NoBuku(2) = 'IF';
Advertisement
Answer
For LAST two letters:
UPDATE tblBuku SET Jenis = 'Informatika' WHERE NoBuku LIKE '%IF'
or
UPDATE tblBuku SET Jenis = 'Informatika' WHERE RIGHT(NoBuku , 2) = 'IF'
For FIRST two letters:
UPDATE tblBuku SET Jenis = 'Informatika' WHERE NoBuku LIKE 'IF%'
or
UPDATE tblBuku SET Jenis = 'Informatika' WHERE LEFT(NoBuku , 2) = 'IF'
Explanation
%
is a wildcard. It indicates one of more of any character.RIGHT
andLEFT
get the substringLEFT(field_name, number of characters to extract from the left)