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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:45:19+00:00 2026-05-18T06:45:19+00:00

Basically I am trying to do a query to a page that holds just

  • 0

Basically I am trying to do a query to a page that holds just an image. I need to provide the tripID number and then the ROWID (as there could be multiple images) to receive a single image. I will be looping until each image is in its corresponding image box in html.

This code doesn’t seem to work(I get Invalid column name ‘ROWID’), but if I remove the AND ROWID=’1′ it returns all the images and its row id like this:

ROWID      PHOTO
    1      32jjr3h2jh23hj4h32jh42ll23j42 
    2       HU8308DJAOID9ASIDJI32C89EE29

–

Select ROW_NUMBER() OVER (ORDER BY Photo ASC) AS ROWID, TBL_Photo.Photo
        From TBL_Photo
        left join TBL_TripDetails
        ON TBL_Photo.TripID=TBL_TripDetails.pkiTripID
        Where pkiTripID = '121' AND ROWID = '1'
  • 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-05-18T06:45:20+00:00Added an answer on May 18, 2026 at 6:45 am

    You can’t reference a column alias in the WHERE clause — you need to use a subquery or a CTE:

    Subquery Example:

    SELECT x.rowid,
           x.photo
      FROM (SELECT ROW_NUMBER() OVER (ORDER BY p.photo) AS ROWID, 
                   p.photo
              FROM TBL_PHOTO p
         LEFT JOIN TBL_TRIPDETAILS td ON td.pkitripid = p.tripid 
             WHERE td.pkiTripID = '121') x
     WHERE x.rowid = 1
    

    CTE example:

    WITH example AS (
            SELECT ROW_NUMBER() OVER (ORDER BY p.photo) AS ROWID, 
                   p.photo
              FROM TBL_PHOTO p
         LEFT JOIN TBL_TRIPDETAILS td ON td.pkitripid = p.tripid 
             WHERE td.pkiTripID = '121')
    SELECT x.rowid,
           x.photo
      FROM example x
     WHERE x.rowid = 1
    

    Performance

    There’s no performance difference between the two options, but the WITH syntax isn’t supported on all databases.

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

Sidebar

Related Questions

Basically I am trying to restart a service from a php web page. Here
Basically I'm trying to accomplish the same thing that mailto:bgates@microsoft.com does in Internet Explorer
I am making a page that accepts post data from any number of pages
Been trying this for quite a while now and I need help. Basically I
So, basically what I'm trying to do is a hockey pool application, and there
I have a query that works fine when there is data but not when
I am trying to query a database basically so it looks like this: $stmt5
I am basically just trying to update multiple values in my table. What would
I'm basically trying to figure out the simplest way to perform your basic insert
I'm basically trying to teach myself how to code and I want to follow

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.