Jump to content

bubblegum.anarchy

Members
  • Posts

    526
  • Joined

  • Last visited

    Never

Posts posted by bubblegum.anarchy

  1. 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
    ;
    

  2. 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
       ...
    

  3. 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.

  4. 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.

     

     

     

  5. 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?

  6. 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.

  7. 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;

  8. 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?

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