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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:16:29+00:00 2026-05-21T16:16:29+00:00

stmt=SELECT * FROM people_? stmt.setString(1, year); The table names that I am trying to

  • 0
stmt="SELECT * FROM people_?"

stmt.setString(1, year);

The table names that I am trying to call are based on year (people_2009, people_2010, etc….), I have the year set to a java variable. I know the code above wont work, because it would put quotes around the year, but is there a way to append the string on the table name, or any other way to go about this?

  • 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-21T16:16:29+00:00Added an answer on May 21, 2026 at 4:16 pm

    You could just do.

    stmt="SELECT * FROM people_" + year;
    

    Which should work fine. Just ensure you properly verify that year variable before appending it, or you might end up with an SQL injection problem. If year is of type int, then no verification would be needed to stop sql injection, but you might want to verify the range to ensure the table exists.

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

Sidebar

Related Questions

I'm writing this in JAVA : stmt.executeQuery(SELECT * FROM mytable INTO OUTFILE '/tmp/mytable.csv' FIELDS
I am trying to fetch and display contents from table.Currently i am running a
I am in trouble with select query ResultSet rs = stmt.executeQuery(SELECT * FROM blogs
I am attempting to execute the following prepared statement: PREPARE stmt FROM 'SELECT *
PROCEDURE A( ... BEGIN stmt := 'select * from '||src; execute immediate stmt; dbms_output.put_line(??);
I am using a SELECT statement to get data from a table and then
Appliction crashes when i'm trying to select data from database and their is no
When I'm trying to fetch data from the sqlite database table the NSArray has
I have a prepared statement like this stmt = select * from table_name where
I have this query and I have an error: images = Image.find_by_sql('PREPARE stmt FROM

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.