Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8917283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:26:58+00:00 2026-06-15T05:26:58+00:00

Hello there i am having little problem. I have two tables in my database.

  • 0

Hello there i am having little problem. I have two tables in my database.
enter image description here

As you can see i am getting all employees in one tab, and what i am trying to achieve here is to display only relevant employees in given tab. So employees from Customer services wont be displayed in Sales tab for example.

$query = mysql_query("SELECT * "."FROM employees, dept_emp "."WHERE employees.emp_no = dept_emp.emp_no");

Thank you for looking and help 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:26:59+00:00Added an answer on June 15, 2026 at 5:26 am

    Your WHERE clause is useless as it is just restating a JOIN condition basically. Try this:

    SELECT *
    FROM employees AS e
    INNER JOIN dept_emp AS de ON e.emp_no = de.emp_no
    WHERE de.dept_no = '?'
    

    Obviously the ? would be substituted with the dept_no value you are actually trying to filter on.

    Per your question about seeting query limits/pagination, that is done via SQL LIMIT clause. The clause can be expressed in a few different ways.

    This first just returns a max number of rows:

    LIMIT 100 <-- shows first 100 rows from the result set
    

    The following two forms of syntax are used for pagination of results:

    LIMIT 0, 100 <-- show first 100 rows from the result set (start at 0 offset, and return a max of 100 rows
    LIMIT 100, 100 <-- show rows 101-200 from the result set (start at 100 offset and return max of 100 rows)
    

    Or:

    LIMIT 100 OFFSET 0 <-- first 100 rows
    LIMIT 100 OFFSET 100 <-- rows 101-200
    

    So putting it all together

    SELECT *
    FROM employees AS e
    INNER JOIN dept_emp AS de ON e.emp_no = de.emp_no
    WHERE de.dept_no = '?'
    ORDER BY e.emp_no
    LIMIT 0,100
    

    Note that I also added an ORDER BY clause. This is important for pagination in that just a regular unordered SELECT doesn’t guarantee order. If you tried to paginate without an ORDER BY you could potentially get the same row returned in multiple “pages”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello @ All out there :) I am having a little problem. I want
Hello there i'm having a problem here i have an add and edit form
After having solved the problem of getting the editor to launch when there's a
Hello I am having trouble getting my Python to work correctly. I have a
Hello fellow developers, I am a little stumped on this one as I have
Hello there im having problem whenever i press the refresh button it keeps adding
Hello i am using SocializeActionBar for my app there i have multiple links. I
Hello I am looking to see if there are any modules for drupal 6
. Hello, I'm using jqueryui's datepicker, and it works great but there's a problem.
Hello there I am having some thoughts on my file structure in codeigniter.What I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.