Jump to content

select query help


will35010

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.