Re: i have two records in select query and it have a two record, then how can i found second record from the result of select query in mysql

From: J.O. Aho <user_at_example.net>
Date: Fri, 14 Apr 2017 08:03:29 +0200
Message-ID: <elb71hFedapU1_at_mid.individual.net>


On 04/14/17 07:06, Mallikarjuna Rao Gudipudi wrote:
> i have two records in select query and it have a two record, then how can i found second record from the result of select query in mysql
>
>
> i have a patient table with details of first name, lastname, date of birth, gender.
>
> my query,
> select first_name, last_name from patient_details where id in (select id from patient_details where last_name = 'madison');
>
> it's gave multiple records, then how can found the second record from the result and how to display the that particular data

In the MySQL documentation about select you would have found your answer: https://dev.mysql.com/doc/refman/5.7/en/select.html

Here is a short how to use LIMIT:
http://www.mysqltutorial.org/mysql-limit.aspx

but LIMIT will be a really poor option here and your query is bad too, as you make two lookups in the database.

You need to do the following:

  • Create an index in which list_name is included.
  • Do use query "select id, first_name, last_name from patient_details where last_name = 'madison'"
  • If this generates more than one option, you need to list them in a list (instead of showing the patient data)
  • From the list the user will select the right user (you need to use the id that you got from the SQL above).
  • Then select further data for the patient selected.

Or the more sensible thing for you to do:

Just keep in mind, the FreeMed may not be certified in your country, so for the sake of your customer, control that it does fulfil all the requirements, or it can be quite costly for you.

-- 

 //Aho
Received on Fri Apr 14 2017 - 08:03:29 CEST

Original text of this message