Jump to content

Recommended Posts

I want to run a select query like: "SELECT visitid FROM visit_data WHERE patientid = '$patientid'";

 

I don't want it to return all the results. I only want the highest numbered visitid. How do I do that?

 

Thanks!

 

Here is the table:

CREATE TABLE IF NOT EXISTS `visit_data` (
  `visitid` int(11) NOT NULL AUTO_INCREMENT,
  `patientid` varchar(45) NOT NULL,
  `date` date NOT NULL,
  `cc` varchar(50) NOT NULL,
  `walkout` varchar(3) DEFAULT NULL,
  `location` varchar(45) NOT NULL,
  `room` varchar(45) DEFAULT NULL,
  `current_status` varchar(45) NOT NULL,
  `reg_time` timestamp NULL DEFAULT NULL,
  `discharged` varchar(45) DEFAULT NULL,
  `discharged_time` timestamp NULL DEFAULT NULL,
  `disposition` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`visitid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

 

 

Link to comment
https://forums.phpfreaks.com/topic/189061-select-query-help/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.