Results 1 to 2 of 2

Thread: problem in where clause to check if the date is exist in another table

  1. #1
    Join Date
    Sep 2010
    Posts
    188

    problem in where clause to check if the date is exist in another table

    Hi..

    I have this code for checking if the date(TIMEOUT) is already exist in nrs table:

    Code:
          $EMP_NO = $_GET['EMP_NO'];
          $DATE_NRS = $_GET['DATE_NRS'];
          $TIME_IN = strtotime($_GET['TIME_IN']);
          $TIME_OUT = strtotime($_GET['TIME_OUT']);
          $APPROVE = $_GET['APPROVE']; 
    
    $sql = "SELECT EMP_NO, TIME_IN, TIME_OUT, TOTAL_HOURS, NRS_STATUS FROM nrs WHERE EMP_NO = '$EMP_NO' AND DATE(TIME_OUT) = '$TIME_OUT'";  
    
    //echo $sql;
      $RsOtData = $conn2->Execute($sql);
      
      $numrows = $RsOtData->RecordCount();
      
      
      if($numrows > 0){ 
      echo "<script>alert('Transaction cannot be process')</script>";
     echo "<script>navigate('NRSEmp.php')</script>";   
      }
      else{
      $saverec['EMP_NO'] = $EMP_NO;
      //$saverec['DATE_NRS'] = $DATE_NRS;
      $saverec['TIME_IN'] = $TIME_IN;
      $saverec['TIME_OUT'] = $TIME_OUT;
      $saverec['TOTAL_HOURS'] = $TOTAL_HOURS;
      $saverec['NRS_STATUS'] = $APPROVE;
      
      $insertSQL = $conn2->GetInsertSQL($RsOtData, $saverec);
      $conn2->Execute($insertSQL); 
      }
    now I need revise my query to check also if the date from $TIME_OUT is equal to reg_att .

    for example of reg_att table data:

    EMP_NO = 00000221
    LOGIN = 2012-03-01 05:35:00
    LOGOUT = 2012-03-01 13:35:00
    if Date from $TIMEOUT = date(LOGOUT) if condition will work.

    I trid this query
    PHP Code:
    SELECT n.EMP_NOn.TIME_INn.TIME_OUTTOTAL_HOURSNRS_STATUS FROM nrs n WHERE EMP_NO '00000221' AND DATE(TIME_OUT) = '2012-03-01' OR DATE(TIME_OUT) = (SELECT DATE(LOGOUTFROM reg_att r WHERE r.EMP_NO n.EMP_NO); 
    and i got an error:

    Error Code : 1242
    Subquery returns more than 1 row
    (0 ms taken)


    Thank you

  2. #2
    Join Date
    Mar 2012
    Posts
    59
    sorry, i am afraid i can not help you. i do not know either.

    Cone crusher | Impact crusher

Similar Threads

  1. Problem in SELECT with DATE RANGE
    By newphpbees in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 17 Apr 2012, 05:27 AM
  2. Problem in WHERE Clause from SELECT Statement
    By newphpbees in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 13 Dec 2011, 07:27 PM
  3. Date Query Problem
    By binarytrends in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 09 Jan 2006, 07:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •