Jump to content

bubblegum.anarchy

Members
  • Posts

    526
  • Joined

  • Last visited

    Never

Everything posted by bubblegum.anarchy

  1. example: id => 1 reaID => '1;2;3;4;2' id => 2 reaID => '1;3;2' the result for reaID = 2 would be: id reaID_count 1 2 2 1 correct ?
  2. extract the index from the column value and apply the appropriate sorting... like this: SELECT substring_index(column_name, ' ', -1) AS column_name_index FROM tabl_name ORDER BY index DESC
  3. To get all work recods with associated user records: SELECT work.work_id , input_user.* , worker_user.* FROM work INNER JOIN user AS input_user ON input_user_id = input_user.user_id INNER JOIN user AS worker_user ON worker_user_id = worker_user.user_id ;
  4. you can always do SELECT company.id AS company_id FROM company and then $row['company_id']
  5. Use an inner join to return only all record in table 2 that have a matching table 1 id.
  6. The calculation can be done in the select query as so: SELECT standings.*, w*3 + pts AS calc FROM standings ORDER BY pts desc, w desc
  7. oh yes, that is great Barand... and ORDER BY pay_date DESC
  8. The following code looks all kinds or wrong to me even through the results appear correct: SELECT * FROM ( SELECT * FROM park ORDER BY pay_date DESC ) AS derived GROUP BY id ORDER BY pay_date DESC;
  9. This is the way I usually check for duplicates: $result = mysql_query("INSERT INTO temp SET content = 'variance'") or mysql_errno() == 1062 or tigger_error(mysql_error(), E_USER_ERROR); if (mysql_errno() == 1062) // handle duplicate ... else ...
  10. I am not sure what the best way is but this is what I do: return "'".(get_magic_quotes_gpc() ? mysql_real_escape_string(stripslashes($value)) : mysql_real_escape_string($value))."'"
  11. You are still probably going to have to poll for changes... keep a simple unix_timestamp field since last change.
  12. WHERE TRUE OR TRUE OR TRUE => will return TRUE WHERE TRUE OR TRUE OR FALSE => will return TRUE WHERE TRUE OR FALSE OR FALSE => will return TRUE and even WHERE FALSE OR FALSE OR TRUE => will return TRUE hence... the return value will be TRUE when at least one of the conditions is TRUE Consider reading up on basic conditional logic.
  13. I got the following information from the mysql website: http://dev.mysql.com/doc/refman/5.1/en/xml-functions.html#function_extractvalue
  14. Concatinating all the conditions with AND means that all conditions must be TRUE for the record to be returned, use OR instead to return the records where only one condition is TRUE... WHERE first = '1st' AND second = '2nd' AND third = '4rd' => WHERE TRUE AND TRUE AND FALSE => will not return the record because not all conditions are TRUE on the other hand.. WHERE first = '2st' OR second = '1nd' OR third = '3rd' => WHERE FALSE OR FALSE OR FALSE => will return the record because at least one of the conditions is TRUE.
  15. MySQL is interpretting the backtick quoted signup string as a table name rather than a string... wrap insert strings with single quotes.
  16. I am not sure inserting into more than one table at a time with the one query is possible.. EDIT just use two queries... how else are you going to link the members_address without an auto increment id of the members_info?
  17. Here is a site that details what a unix timestamp is: http://www.unixtimestamp.com/ Simply put a unix time is the amount of seconds since an epoch (a particular point in time), the epoch is defined by the unix system is 1970-01-01 00:00:00, so the a function call to unix_timestamp() return the number of seconds that has passed since 1970-01-01 00:00:00. The unix timestamp is an effective way to sort dates.
  18. I am not so sure the query you posted provides the correct records - lets get other opinions.
  19. `AS derived` is an alias for the resulting recordset produced via this `(SELECT * FROM temp ORDER BY lastdate DESC)` - you can have AS any_alias_name_u_like_that_is_not_a_reserved_word
  20. so what you actually want is simply this: SELECT * FROM (SELECT * FROM temp ORDER BY lastdate DESC) AS derived GROUP BY id; and you will find that DanDaBeginner was right in the first place when suggesting my initial query was erroneous
  21. I am not sure what you mean and you haven't answered my original questions dabip... your answers will help me better understand what you are trying to achieve. DanDaBeginner - what do you think of this query? - might be just what dabip needs. SELECT * FROM (SELECT * FROM temp ORDER BY id, lastdate DESC) AS derived GROUP BY id;
  22. saying that you only want rows where the id2 = 0 means that you want a WHERE id2 = 0 in your query... correct me if I am wrong but does not max(id2) = the most recently post in a thread ? so for each unique id you want the record with the max(id2) or for each unique id you want the record with the most recent lastdate right?
  23. You are right DanDaBeginner, my original query is all wrong... just happened to work.
×
×
  • 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.