hi all,

i had a query and i need to substr that query.

@s ="select Emp_Id,First_Name,Last_Name,Gender,Mobile_No,Email_id,Blood_Group from Employee where Emp_ID like '%", empid ,"%' and

my query is this
now i used substr

set str1 = (SUBSTR(@s,-4));

SO in str1 i am getting values as 'and'...Now i dont need and value i need remaining one i;e

select Emp_Id,First_Name,Last_Name,Gender,Mobile_No,Email_id,Blood_Group from Employee where Emp_ID like '%", empid ,"%'

how to get that in str1... can any one help me..

You are confusing levels. On one level (presumably PHP) you are building your query, on the MySQL level you are executing it.
To get rid of the the trailing " and" in your query use something like
$query = substr($query, 0,length($query)-4)
or whatever is appropriate in the used language.
Alternatively just add a "1" to your query like in

SELECT something FROM mytable WHERE condition1 and condition2 and 1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.