Skip to content
Advertisement

Run all SQL files in a directory

I have a number of .sql files which I have to run in order to apply changes made by other developers on an SQL Server 2005 database. The files are named according to the following pattern: Is there a way to run all of them in one go? Answer Create a .BAT file with the following command: If you need

MySQL: Order by field size/length

Here is a table structure (e.g. test): Field Name Data Type id BIGINT (20) title varchar(25) Description Text A query like: But I would like to order by the field size/length of the field description. The field type will be TEXT or BLOB. Answer The LENGTH function gives the length of string in bytes. If you want to count (multi-byte)

How to search multiple columns in MySQL?

I’m trying to make a search feature that will search multiple columns to find a keyword based match. This query: works only for searching one column, I noticed separating column names with commas results in an error. So is it possible to search multiple columns in mysql? Answer You can use the AND or OR operators, depending on what you

Python: Number of rows affected by cursor.execute(“SELECT …)

How can I access the number of rows affected by: Answer Try using fetchone: result will hold a tuple with one element, the value of COUNT(*). So to find the number of rows: Or, if you’d rather do it in one fell swoop: PS. It’s also good practice to use parametrized arguments whenever possible, because it can automatically quote arguments

how does a SQL query work?

How does a SQL query work? How does it get compiled? Is the from clause compiled first to see if the table exists? How does it actually retrieve data from the database? How and in what format are the tables stored in a database? I am using phpmyadmin, is there any way I can peek into the files where data

How does contains() in PL-SQL work?

Have a lot of unnecessary results using contains() method in my query. Don’t tell me to use like or something else. It is hardcoded and couldn’t be changed. Answer Contains is used on text fields that have a ‘CONTEXT Index’, which indexes a text field for searching. The standard usage is like this (using the score operator to display what

Advertisement