Results 1 to 9 of 9

Thread: MSSQL database

  1. #1
    Join Date
    May 2010
    Posts
    6

    Unanswered: MSSQL database

    Hello Everybody,

    I'm working on a project for a work agency in the Netherlands.I made a java application for the workers to see what time they work at which company and which car they have to take to get there.

    I want to retrieve this information from a MSSQL database into my java app into jtabels. The only problem i have is the MSSQL query to accomplish this.

    These are the tables in my mssql database on a ms sql server:

    tbl.EmployeeEmployee_ID PK
    Employee_Name
    Employee_House

    tbl.EmployeeAssignment
    Employee_ID
    Assignment_ID

    tbl.Assignment
    Assignment_ID PK
    Company_ID
    Starttime
    PickupTime

    tbl.Company
    Company_ID PK
    Company_Name
    Company_Info

    tbl.Assignment
    Car
    Car_ID
    Assignment ID

    tbl.Car
    Car_ID PK
    Car_Number
    Car_Location
    Car_People

    My goal for now is to select ALL from tbl.car where Employee_ID is "myID" and Assigment_ID is one of the maximum 2 IDs there are for a certain Employee.

    Every Employee can work at more companies and every company has more employees. For every company there can be more cars assigned to it.

    I have to finish this project soon and i really don't know how to fix this.I hope you guys can help me...

    thanks

    ps. if you want more details let me know....

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by mitgeld View Post
    ... and Assigment_ID is one of the maximum 2 IDs there are for a certain Employee.
    please explain this in more detail
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    May 2010
    Posts
    6
    I mean with this that every employee can have more assignments to his/her name. I want to show all those assignments but not in the same table. The ID's for this assignments are random ints.

    i hope you understand and can help me. i really have to finish this soon. and any help would be great.

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    i still don't understand the "maximum 2" part

    maybe you could describe what you want by giving sample rows for each of your tables, and then showing what the results should be from the query for the sample data
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    May 2010
    Posts
    6
    the maximum assignments there are for one employee is 2.

  6. #6
    Join Date
    May 2010
    Posts
    6
    i will make you an example now, i ll post it in a bit

  7. #7
    Join Date
    May 2010
    Posts
    6

    example table and results

    my first attachment to this post is an example off my database.
    the second one is is an example of the result i want to get.

    as you can see there are 4 tables, 2 for the employees assigments and 2 for the transportation to that assigment. here you can see what i ment with 2 assigment for 1 employee.

    every employees logs in in my java app and will have a overlook where they have to work, with who and how he/she will go there.

    i really hope you can help me. thanks
    Attached Thumbnails Attached Thumbnails Picture 1.png   Picture 2.png  

  8. #8
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    please do me a favour and export your spreadsheet to a text file, not an image
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  9. #9
    Join Date
    May 2010
    Posts
    6
    please man,

    its readable like this.
    can you please help me

Posting Permissions

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