Is there an alias for using * in SQL?

59 Views Asked by At

Protecting mySQL queries by algorithms needs knowledge about exploits. Thus I'm checking the query whether it contains *. How to avoid using * in mySQL queries by using alternative syntax? Are there ways to show all database content without using SELECT * FROM

many thanks

1

There are 1 best solutions below

9
Bill Karwin On

The * wildcard means all columns of the table(s) referenced in the query.

The alternative that doesn't use * is to spell out the names of the columns:

SELECT column1, column2, column3, ... FROM ...

In my opinion, an algorithm that counts any SQL query that contains * as an exploit is designed wrong. There are many legitimate uses of that symbol in SQL queries. You might as well count any query that contains an OR boolean operator as an exploit (I have read about so-called security tools that do this, and it's just as misguided).