Aptitude (12) ASP.NET (2) Automata (4) Browser (1) C (5) C# (1) C++ (10) Code (3) CSS (1) Data Structure (1) DATABASE (3) HTML (1) java (43) JSP (1) math (1) MySql (8) other (6) php (3) Servlet (3)

Friday, 30 November 2012

String operations in Database:


In order to compare an attribute with string,it is required to surround the string by apostrophes ,e.g where LOCATION=’DALLAS’.A powerful operator for pattern matching is the like operator . Together with this operator ,two special characters are used ;the percent sign % (also called wild card),and the underline _,also called position marker e.gif one is interested in all tuples of the table DEPT that contain two C in the name of the department ,the condition would be where DNAME like “%C%C%”.the % sign means that any (sub)string is allowed there ,even the empty string .in contrast ,the underline stands for exactly one character .Thus the condition where DNAMElike “%C_C%” would require that exactly one character appears between the two Cs .To test  for inequality ,the not clause is used.
Further string operation are :
1.upper
2.lower
3.initcap
4.length
5.substr

No comments:

Post a Comment