Jump to content

JipThePeople

Members
  • Posts

    51
  • Joined

  • Last visited

Everything posted by JipThePeople

  1. Thx so much for the response. My table has 9 records (currently) for 3 different file id's (i.e., I need to retrieve the most recent record for each file id = 3 records returned). Unfortunately, the query you provided returns multiple records for each file_id. Any other ideas will be great appreciated.
  2. I have a table containing records of files and scores which also contain a date the record was inserted and the file_id as well as other fields. I want to select the most recent score for each file_id. For instance, there will be multiple records for a file_id corresponding to the latest score assigned to that file. There will be different file_id's in the table each with multiple records. My goal is to select one record per each unique file_id retrieving only the last record inserted (per the submit_date field). I can retrieve a single record (the most recent record inserted) with this query, but I need the most recent record for each unique file_id in the table. SELECT `score` FROM `file_grade_answers` WHERE `submit_date` = (SELECT MAX(`submit_date`) FROM `file_grade_answers`) Here is the table I am using for this question: CREATE TABLE IF NOT EXISTS `file_grade_answers` ( `filegrade_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `file_id` int(10) unsigned NOT NULL, `reviewer_id` varchar(100) NOT NULL, `owner_at_review` varchar(100) NOT NULL, `process_at_review` int(10) unsigned NOT NULL, `question_ids` varchar(100) NOT NULL, `answers` varchar(100) NOT NULL, `recommendations` blob NOT NULL, `submit_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `possible_points` int(10) unsigned NOT NULL, `actual_points` int(10) unsigned NOT NULL, `score` int(10) unsigned NOT NULL, PRIMARY KEY (`filegrade_id`) ) Any advice will be greatly appreciated.
  3. Thx for the replies. I had to do it this way: SELECT * FROM `users` WHERE `last_name` >='A' AND `last_name` < 'G' This query returns records as expected.
  4. Query does not throw an error (i.e., syntax is good), it just won't return any records and there are user names in the table with last names that begin with the range of letters.
  5. Unfortunately, all I can find is LIKE '[A-F]%' But that doesn't work with MySQL. Has anyone else had this issue?
  6. MySQL version: 5.1.54-community I am executing the SQL within PHP MyAdmin 3.3.8.1 This will successfully return records (last names beginning with 'B'): SELECT * FROM `users` WHERE `last_name` LIKE 'B%' However, this query is SUPPOSED to return records of users with last names that begin with letters A-F: SELECT * FROM `users` WHERE `last_name` LIKE '[A-F]%' Here is the table I am querying: CREATE TABLE IF NOT EXISTS `users` ( `userid` varchar(25) NOT NULL DEFAULT '', `first_name` varchar(50) NOT NULL DEFAULT '', `last_name` varchar(50) NOT NULL DEFAULT '', `email` varchar(100) NOT NULL DEFAULT '', `work_address1` varchar(100) NOT NULL DEFAULT '', `work_address2` varchar(100) DEFAULT '', `work_city` varchar(100) NOT NULL DEFAULT '', `work_state` char(2) NOT NULL DEFAULT '', `work_zip` varchar(10) NOT NULL DEFAULT '', `home_address1` varchar(100) DEFAULT '', `home_address2` varchar(100) DEFAULT '', `home_city` varchar(100) DEFAULT '', `home_state` char(2) DEFAULT '', `home_zip` varchar(10) DEFAULT '', `work_phone` varchar(20) NOT NULL DEFAULT '', `home_phone` varchar(20) DEFAULT '', `mobile_phone` varchar(20) DEFAULT '', `fax` varchar(20) DEFAULT '', `primary_phone` varchar(100) NOT NULL DEFAULT '', `manager` varchar(100) DEFAULT '', `connection_type` varchar(100) DEFAULT '', `organization` varchar(255) DEFAULT NULL, `group_id` int(10) unsigned DEFAULT '1', `must_update` int(2) unsigned NOT NULL DEFAULT '0', `must_change_pw` int(1) unsigned NOT NULL DEFAULT '0', `last_updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `use_cached_login` int(1) unsigned NOT NULL DEFAULT '0', `active` int(2) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`userid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; My goal is to select users with last names that begin with a range of letters (e.g., A-F). Any help is greatly appreciated.
  7. Wanting to add ORDER BY to sort items grouped as a result of the GROUP_CONCAT. Any recommendations? SELECT `t1`.`id`, `t1`.`filename`, `t2`.`process`, `t3`.`folder_name`, `t3`.`userid` AS `folder_userid`, `t1`.`inout`, `t1`.`userid`, `t1`.`last_updated`, `t1`.`filesize`, `t1`.`pagecount`, GROUP_CONCAT(`t4`.`comment` SEPARATOR ' | ') AS `concat_comments` FROM (`proposal_files` AS `t1` JOIN `prop_file_processes` AS `t2` ON `t1`.`process` = `t2`.`id`) JOIN `folders` AS `t3` ON `t1`.`folder` = `t3`.`id` LEFT JOIN `prop_file_version_comments` AS `t4` ON `t1`.`id` = `t4`.`fileid` WHERE `t1`.`propid` = " . sql_quote($_SESSION['current_prop_id'])
  8. Thx, that was exactly what I needed. I had to tweak a things (h1.id, h1 duplicated - changed to v1, v1.id) but it works great. Thanks for the solution!
  9. Can you please give me an example? Won't two JOINS = 2 queries? I am trying to keep it to a single query.
  10. Thx for the reply. I am trying to query multiple tables I have a 'teams' table that has columns for 'id' and 'city' + 'mascot' = team name. I have another table, 'schedules' that has records containing the two teams (id's) that are to play. I am trying to accomplish this in a single query rather than two. Any recommendations? Thx again for your time.
  11. I get an error "#1241 - Operand should contain 1 column(s) " when executing this code: SELECT `game_datetime`, `home_team_temp`, `visiting_team_temp`, (SELECT CONCAT(`mascot`, ' ', `city`) AS `home_team`, `logo_url` AS `home_logo_url` FROM `teams`, `logos`, `schedules` WHERE `teams`.`id` = `logos`.`team_id` AND `teams`.`id` = `schedules`.`home_team_id`), (SELECT CONCAT(`mascot`, ' ', `city`) AS `visiting_team`, `logo_url` AS `visiting_logo_url` FROM `teams`, `logos`, `schedules` WHERE `teams`.`id` = `logos`.`team_id` AND `teams`.`id` = `schedules`.`visiting_team_id`) FROM `schedules`, `teams` WHERE `teams`.`id` = `schedules`.`visiting_team_id` OR `teams`.`id` = `schedules`.`home_team_id` Any suggestions?
  12. Well I found the solution (thx litebearer!): function curl_get_file_contents($URL){ $c = curl_init(); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_setopt($c, CURLOPT_URL, $URL); $contents = curl_exec($c); curl_close($c); if ($contents) return $contents; else return FALSE; } // Google API code function GetTemperature($what_zip) { $url = "http://www.google.com/ig/api?weather=" . $what_zip; // Web host disabled file_get_contents(), so this is the workaround $file = curl_get_file_contents($url); $needle = '<temp_f data="'; $marray = explode($needle, $file); $marray2 = explode('"', $marray[1]); return $marray2[0]; } $city_array = array ("48185", "90032","39350","23452"); $count = count($city_array); $i = 0; while($i<$count) { $zip = $city_array[$i]; echo $zip . " is " . GetTemperature($zip) . " degrees F<br>"; $i++; }
  13. Thx litebearer. Looks like this is exactly the code I was looking for. Unfortunately, my web host has the URL file-access is disabled: "Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration" I think your code can be altered to use curl functions as a work around. Do you know how to edit the Google code to use curl? Any advice will be greatly appreciated.
  14. I am looking for the easiest way to get live data for the current temperature for various U.S. cities. I just need to capture the data and display on the page. Any recommendations?
  15. Thx for the reply and the information.
  16. I am running php 5.3.2 on Win Server 2008 R2 (IIS 7). When I execute the mkdir() function and pass it a string (i.e., the path) longer than 256 characters, it throws an error indicating "result too large". My question is whether this is because the mkdir() function cannot handle a string larger than 256 char or if it is a Windows issue on max characters allowed (path length). Any feedback or recommendations will be appreciated.
  17. That's the solution. Thanks for your time!
  18. Thx for the replies. I am struggling with the syntax. Could please provide an example?
  19. I have a the following query that ends up returning two records for the same file, provided they have 2 comments associated with them (i.e., one record with multiple comments). A given file can have more than one comment assigned to it, which is why this query will return two records for the same file provided there are multiple comments assigned. SELECT `t1`.`filename`, `t2`.`comment` FROM `proposal_files` as `t1` LEFT JOIN `prop_file_version_comments` as `t2` ON `t1`.`id` = `t2`.`fileid` WHERE `t1`.`propid` = '202' ORDER BY `t1`.`filename` ASC I need to perform some sort of a CONCAT function so that query returns a single record but combines all comments into a single comma-separated field. Here are the respective tables: CREATE TABLE IF NOT EXISTS `proposal_files` ( `id` int(10) unsigned NOT NULL auto_increment, `propid` int(10) unsigned NOT NULL default '0', `filename` varchar(255) NOT NULL default '', `inout` int(10) unsigned NOT NULL default '0', `folder` int(10) unsigned NOT NULL default '0', `process` int(10) unsigned NOT NULL default '0', `userid` varchar(100) NOT NULL default '', `owner` varchar(100) NOT NULL default '', `filesize` varchar(50) default NULL, `pagecount` int(10) unsigned default NULL, `created` datetime NOT NULL default '0000-00-00 00:00:00', `last_updated` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`) CREATE TABLE IF NOT EXISTS `prop_file_version_comments` ( `id` int(10) unsigned NOT NULL auto_increment, `fileid` int(10) unsigned NOT NULL default '0', `current_version` int(1) unsigned NOT NULL default '0', `comment` blob NOT NULL, `commenter` varchar(100) NOT NULL default '', `timestamp` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=119 ; Any suggestions will be greatly appreciated.
  20. Solution was just to change auth type from cookies to http: $cfg['Servers'][$i]['auth_type'] = 'http';
  21. I have also tried version 3.1.1 but it has the same issue with mcrypt. Any feedback will be greatly appreciated.
  22. I have installed phpMyAdmin 3.0.1.1 on WinXP Pro with PHP 5.2.8. When I browse to the login page, I see the following error message: "Cannot load mcrypt extension. Please check your PHP configuration." I have tweaked my php.ini file to load the mcrypt extension and my phpInfo() page is indicating that other extensions have successfully loaded (e.g., mySQL, LDAP). I have verified that there is a "php_mcrypt.dll" file in the extensions folder. The only solution I found was dealing with libmcrypt.dll and putting it in my System32 folder. I did this and nothing has changed. Any recommendations?
×
×
  • 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.