Skip to content
Advertisement

Tag: sql

Check empty select in sqlite?

How can i check the result of my query? I try this, but when the result is empty – error doesn’t shows. Answer Note that sqlite_fetch_array() returns a result handle, not the number of rows, so you should not compare it against zero: This function will return a result handle or FALSE on failure. Use sqlite_num_rows() to determine the number

selecting unique values from a column

I have a MySQL table which contains the following type of information: Here is an example of a script I use to get data from this table: This script displays every date from the table, e.g. I would like to only display unique dates, e.g. Answer Use the DISTINCT operator in MySQL:

Select Random Row from SQL Using PHP

I want to request 5 random rows from my SQL table using php. for instance, i need to: Answer Edit: For what its worth, Please note that using rand() on a table with large number of rows is going to be slow. This can actually crash your server. Some Solution: MediaWiki uses an interesting trick (for Wikipedia’s Special:Random feature): the

Search with full name instead of just first name or last name

I am developing an API built with PHP and Codeigniter and I use MySQL as database. I have a user table called Users which contains the following columns: How can a user search this table using a full name? For example it works fine to search either by Martin or Smith, but not Martin Smith. This is the query I

IMDB to MySQL: Insert IMDB data into MySQL database

I’m looking for a solution to import all the IMDB data into my own MySQL database. I’ve downloaded all the IMDB data files from their homepage which are all in the file format *.list (in Windows). I want to retrieve and that information and insert it correctly into my MySQL database so I can do some test and query searches.

How to optimize a query with MySQL multi-query?

I need to optimize a script for high performance so the question is how can I add MySQL multi-query to this code? Answer If you’re using mysqli or PDO already, you should be using prepared statements for your queries since they are supported. This will also have a slight increase in performance since the entire query doesn’t need to be

Purpose of Secondary Key

What is the purpose of the Secondary key? Say I have a table that logs down all the check-ins (similar to Foursquare), with columns id, user_id, location_id, post, time, and there can be millions of rows, many people have stated to use secondary keys to speed up the process. Why does this work? And should both user_id and location_id be

Doctrine 2: Update query with query builder

Hi I’ve got the following query but it doesn’t seem to work. This returns the following error message: Fatal error: Uncaught exception ‘DoctrineORMQueryQueryException’ with message ‘[Semantical Error] line 0, col 38 near ‘testusername WHERE’: Error: ‘testusername’ is not defined.’ in … I would be glad of any help Answer I think you need to use ->set() It’s much safer to

Advertisement