LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 07-08-2009, 01:02 PM   #1
Mike1569
LQ Newbie
 
Registered: Jul 2009
Posts: 2

Rep: Reputation: 0
mysql query two tables please Help


I feel like Iím so close but cant get there, I have two tables, employees and job employees holds all employees data and job holds time card info. Iím making a form that displays the employees that have turned in time cards and the ones that have not. I can get the ones that have

Code:
$query1 = "SELECT DISTINCT Employee FROM job where Date='$date'";
But getting the ones that have not is a lot harder this is what I have

Code:
$query2 = "SELECT DISTINCT a.first_name
    FROM employees a
    left outer join job b
        on a.first_name=b.employee
    WHERE a.level='5' and b.date !='$date'";
This works fine tell the next day when employees post that days cards it will show them as both having a card and not having a card. The level= filters the list for shop employees or inactive employees
any ideas
 
Old 07-08-2009, 02:25 PM   #2
Mike1569
LQ Newbie
 
Registered: Jul 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Cool

Found the sulution

Code:
$query2 = "SELECT first_name FROM employees where first_name not in (SELECT employee FROM job where Date='$date') and level='5'";
It works yaaaaaa Thanks you all you help
 
Old 07-09-2009, 01:31 AM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
In the long run you'll find having/using an employee_id is guaranteed to keep people separate when they have the same name.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql tuning problem: show query and fragmented tables! gavin2u Linux - Server 1 02-12-2009 07:32 PM
MySQL - Query and compare 2 tables rookiepaul Programming 4 05-12-2008 10:05 AM
help with mysql query: return nth rows in query hawarden Programming 2 07-31-2006 07:36 PM
mysql reinstallation distorted by previous tables in /var/mysql mad4linux Linux - Software 0 10-04-2005 02:39 PM
SQL query, comparing tables ngomong Programming 3 07-07-2002 08:44 PM


All times are GMT -5. The time now is 08:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration