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

The Archive Base Latest Questions

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

Is it possible to have a subquery modifying the database in a SELECT-Query? The

  • 0

Is it possible to have a subquery modifying the database in a SELECT-Query? The relevant database is a mysql database.

Some more details:
The relevant query looks like this:

SELECT * FROM table WHERE id = $x

And the variable $x can be replaced with anything. The only restriction is, that the query is executed via php’s mysql_query(), which prevents the execution of multiple subsequent queries. In that case, modifying the DB would be easy, simply set

$x = "42; DROP TABLE foo;"
  • 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-29T16:50:32+00:00Added an answer on May 29, 2026 at 4:50 pm

    EDIT:

    mysql_query() only prevents multiple queries in versions of MySql earlier than 5.0. MySql 5.0 or later will allow multiple commands separated by ; when using mysql_query().

    So, yes, a SQL Injection attack is capable of doing whatever commands the login used to connect to the database has permissions to do.

    If you connect using admin privileges, the attack could do essentially any possible modification to your database.

    For example, say that you concatenate the $email value to the SQL string below:

    "SELECT email, passwd, login_id, full_name
      FROM members
     WHERE email = '" + $email + "'"
    

    But lets say that the $email value contains the string:

            x';INSERT INTO members ('email','passwd','login_id','full_name') 
            VALUES ('steve@unixwiz.net','hello','steve','Steve Friedl');--
    

    You end up with the following statement:

    SELECT email, passwd, login_id, full_name
      FROM members
     WHERE email = 'x';
            INSERT INTO members ('email','passwd','login_id','full_name') 
            VALUES ('steve@unixwiz.net','hello','steve','Steve Friedl');--';
    

    Even if modifications weren’t allowed by the login that you’re using to connect to the database, SQL Injection attacks could be used to scrape every bit of data our of your database…

    It’s definitely recommended that you protect yourself by using some form of parameterized queries in your client application.

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

Sidebar

Related Questions

I have a general query that looks like this: SELECT DISTINCT pb.id, pb.last, pb.first,
I have a query that looks something like SELECT to_number FROM sent_texts WHERE to_number
so suppose I have this query SELECT COUNT(*) FROM (SELECT * FROM k JOIN
I have something like ( COMPLEX_EXPRESSION_N stands for a long subquery) select ID_Operation, FirstCheck
I have this query: SELECT DISTINCT id, label FROM bbproduct_cust WHERE CUSTNO IN (SELECT
I have a query that searches for the all rows in some distance according
Is it possible to have a DESCRIBE table clause inserted as a subquery in
I have the following SQL query: select expr1, operator, expr2, count(*) as c from
I have a mysql DB with two tables: messages message_answers I'd like to fetch
I have the following query: SELECT AVG(time) FROM (SELECT UNIX_TIMESTAMP(max(datelast)) - UNIX_TIMESTAMP(min(datestart)) AS time

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.