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 87817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:27:44+00:00 2026-05-10T22:27:44+00:00

I have two tables with the following columns: table1: id, agent_name, ticket_id, category, date_logged

  • 0

I have two tables with the following columns:

table1:

id, agent_name, ticket_id, category, date_logged 

table2:

id, agent_name, department, admin_status 

What I’m trying to achieve is to Select all rows from table1 where an agents department is equal to that of table2.

I’ve tried a few different join statements but I’m either getting the syntax wrong or it just won’t work with this table setup. I’m a beginner when it comes to MySQL and from what I’ve read JOIN’s are at the complex end of the spectrum!

One other option I’ve considered is duplicating the column ‘department’ into table1 but that will require a little bit more coding on the frontend and I’m trying to see if I can achieve the desired result without doing that.

Any assistance greatly appreciated.

  • 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. 2026-05-10T22:27:45+00:00Added an answer on May 10, 2026 at 10:27 pm

    I don’t quite understand your question… Only table2 have a department, the only thing they have in common is agent_name.

    I do suspect what you really mean is: that you want all rows from Table1 where the agent is from a certain department, is that what you want? In that case, something like this should do it (haven’t tested it though):

    SELECT * FROM Table1        INNER JOIN Table2        ON Table1.agent_name = Table2.agent_name        WHERE Table2.department = 'somespecific value'; 

    BTW: (Inspired by what someone else said) agent_name sounds like it’s a string value, you really should consider using the id from table2 as a key in table1 (let’s call it agent_id perhaps) to link them together. The foreign keys (the link between tables) should be a real unique id. The department should pobably allso be a id key. Then it would be:

    SELECT * FROM Table1        INNER JOIN Table2        ON Table1.agent_id = Table2.id        WHERE Table2.department = 'somespecific value'; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 77k
  • Answers 78k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You don't care about the user's connection type, you care… May 11, 2026 at 3:37 pm
  • added an answer If the id field is an autogenerated (identity/guid) field, the… May 11, 2026 at 3:37 pm
  • added an answer You can use the attribute ends with selector: $('tag[id$='ServerSideId']') Where… May 11, 2026 at 3:37 pm

Related Questions

NHibernatians! I have a table [dbo].[Wibble] and another table [dbo].[WibbleExtended]. [Wibble] is the main
So my goal here is to have a single search field in an application
Given the following tables in ActiveRecord: authors sites articles I don't know how to
I have two tables, we'll call them Foo and Bar , with a one

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.