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

  • SEARCH
  • Home
  • 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 9319579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:25:12+00:00 2026-06-19T03:25:12+00:00

so i have 5 tables in which it is interconnected with foreign keys and

  • 0

so i have 5 tables in which it is interconnected with foreign keys

5tables

and here is a sample output of table 3

table3output

what i wanted to do in table number 3 is to extract the SubdeptID of user with userid of 10 but in this case it has 2 userid10 so its print both. what i want to print is only the one with latter TransferID. my select statement is this

$sql_exp = "SELECT  a.UserID, b.Employeename, c.TransferID, e.Department
FROM    dbo.FA_Laptop a
        INNER JOIN dbo.users b
        on a.UserID = b.UserID
        INNER JOIN dbo.SubDeptTransfer c
            ON a.UserID = c.UserID  
        INNER JOIN dbo.SubDept d
            ON c.SudDeptID = d.SubDeptID
        INNER JOIN dbo.departments e
            ON d.DeptID = e.DeptID
WHERE  a.FAID = '$faidf' ORDER by c.TransferID DESC LIMIT 1"; 

my php code is

$rs = $conn->Execute($sql_exp);      
    if ($rs->EOF) {
    echo "<tr><td>Please check for the Employee Name or the Department</td>";
} else {
    while (!$rs->EOF){ 
    echo "<tr><td>".$rs->Fields("Department")." / ".$rs->Fields("EmployeeName")."</td>";
    $rs->movenext();
    }
       $rs->Close();  
}   

im having an error in “LIMIT” query.

  • 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-19T03:25:14+00:00Added an answer on June 19, 2026 at 3:25 am

    MSSQL don’t have LIMIT keyword.

    Use TOP instead LIMIT.

    $sql_exp = "SELECT TOP 1 a.UserID, b.Employeename, c.TransferID, e.Department
    FROM    dbo.FA_Laptop a
            INNER JOIN dbo.users b
            on a.UserID = b.UserID
            INNER JOIN dbo.SubDeptTransfer c
                ON a.UserID = c.UserID  
            INNER JOIN dbo.SubDept d
                ON c.SudDeptID = d.SubDeptID
            INNER JOIN dbo.departments e
                ON d.DeptID = e.DeptID
    WHERE  a.FAID = '$faidf' ORDER by c.TransferID DESC"; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several tables which reference one main table using foreign keys. My goal
I have number of tables which contain temperature variable. Moreover I have a table
I have 2 tables which looks like this: ARTICLES TABLE: and the output should
Suppose I have many tables which have Foreign keys created. I want to get
I have 2 tables which I want to query from. The first table (lets
I have two tables which looks something like this Table Queue int ID; string
I have three tables which are defined as: class User(Base): __tablename__ = 'users' id
I use Hibernate with Java. I have two tables which are associated with foreign
I have two tables which I need to join. First Table: EFF_DATE RATE CURRENCY
I have tables which looks like below. Employee table Date Employee ID Employer ID

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.