in my form having three textboxes for First Name, Middle Name, Last Name, and some textboxes for other details to store in db.
now if user enter firstname and last name in textbox and enter name is blocked in application so one popup page should be open and should be display record like, name, address, mono, and photo.
i tried to solve this but issue is the query should be validate probality for blocked person. like if first name's 4 character and last name's 4 character's probality should be validate...
second issue is the name is stored in single column in table.
after popup open user should move record next or preveous to check propbality of blocked persons in application.
i tryied as below...
how to make query to find probality of blocked person for first 4 and last 4 character from table....
query += "SELECT * FROM (";
query += " SELECT ROW_NUMBER() OVER(ORDER BY ID) AS 'RowNo',";
query += " NAME,ADDRESS,CITYORVILLAGE,TALUKA,DISTRICT,CONTACTNO,(SELECT COUNT(*) FROM RESTICTIED_PERSONS) AS 'Total'";
query += " FROM RESTICTIED_PERSONS";
query += ") t ";
query += "WHERE t.RowNo = @Row";
Muhammad Imran AnsariPosted Mar 29, 2022, 10:07 AM
Bhavesh VankarPosted Mar 29, 2022, 6:50 AM
Muhammad Imran AnsariPosted Mar 28, 2022, 1:51 PM
You can use LEFT and RIGHT functions to get the name first 4 and last characters. change your query accordingly.
Example:
First Name: William
Last Name: John
In your case, first and last name is storing in 'Name' field. Name: William John
SELECT LEFT(Name, 4) FirstFour, RIGHT(Name, 4) AS LastFour;
SELECT ROW_NUMBER() OVER(ORDER BY ID) AS 'RowNo',
NAME,ADDRESS,CITYORVILLAGE,TALUKA,DISTRICT,CONTACTNO,(SELECT COUNT(*) FROM RESTICTIED_PERSONS) AS 'Total'
FROM RESTICTIED_PERSONS
WHERE LEFT(Name, 4) = @FirstFour AND RIGHT(Name, 4) = @LastFour