mysql

PHP Function Abuse?

I have a large system that I have coded and I wish to make the code (dare I say) more simple and easy to read. Unfortunately before this, I haven't used functions much. I have many different MySQL Queries that are run in my code, I feel that if I make the various displays into functions and store them in a separate file it would make t...

ASP .NET - Configure SQLDataSource to use MySQL .NET Connector

I am using VS 2008. Looking around on the forums/stack hasn't provided a clear answer on how to use MySQL with a ASP .NET site. How do I configure a SQLDataSource to use MySQL by using the MySQL Connector NET provider? I would prefer not to use the ODBC driver - which I can get working. The connector has been added as a reference t...

How to generate unique URL variables that match to a db record?

Hello all, I wish to be able to generate URL variables like this: http://example.com/195yq http://example.com/195yp http://example.com/195yg http://example.com/195yf The variables will match to a MySQL record set so that I can pull it out. At the time of creation of that record set, I wish to create this key for it. How can I do th...

MySQL Inserting large data sets from file with Java

I need to insert about 1.8 million rows from a CSV file into a MySQL database. (only one table) Currently using Java to parse through the file and insert each line. As you can imagine this takes quite a few hours to run. (10 roughtly) The reason I'm not piping it straight in from the file into the db, is the data has to be manipula...

MySQL "Group By" and "Order By"

I want to be able to select a bunch of rows from a table of e-mails and group them by the from sender. My query looks like this: SELECT emailID, fromEmail, subject, timestamp, MIN(read) as read FROM incomingEmails WHERE toUserID = '$userID' GROUP BY LOWER(fromEmail) ORDER BY timestamp DESC The query almost works as I want it--it s...

What does this code do?

while (list($task_id, $parent_id, $task) = mysqli_fetch_array($r, MYSQLI_NUM)) ...

Overly specific mysql query not working

I have written a query to find similar ids based on tags from a current id, much like amazons, you would also like. The problem is, in my example I want to exclude bookid 30 from this search. Here is my query: note: $similar is basically a string filled with tags built up with a few "like %item% or" $query = "SELECT * FROM books ...

Optimize SELECT DISTINCT CONCAT query in MySQL

Hello! I'm running this query: SELECT DISTINCT CONCAT(ALFA_CLAVE, FECHA_NACI) FROM listado GROUP BY ALFA_CLAVE HAVING count(CONCAT(ALFA_CLAVE, FECHA_NACI)) > 1 Is there any way to optimize it? Queries are taking 2-3 hours on a table with 850,000 rows. Adding an index to ALFA_CLAVE and FECHA_NACI would work? Thanks in advanced ...

Storing EXIF information in Database

What's the best way to store EXIF data from photos in a Database (MySQL in my case). This is for a photo sharing site. What are the most important Tags, and what are discardable? ...

Applying DATABASE_OPTIONS when testing Django project (or make it to use InnoDB for MySQL)

As the title says, I want to apply DATABASE_OPTIONS settings when I run my tests via ./manage.py test. In django/db/backends/creation.py, it does not consider this option at all in both create_test_db() and _create_test_db(). This breaks a test with a view that uses transaction.rollback function with InnoDB. It seems that test databases...

MySQL: JOIN queries vs multiple queries

Are JOIN queries faster than several queries? (You run your main query, and then you run many other SELECTs based on the results from your main query) I'm asking because JOINing them would complicate A LOT the design of my application If they are faster, can anyone approximate very roughly by how much? If it's 1.5x I don't care, but if...

explain the USING command

Take a look... http://search.mysql.com/search?site=refman-41&q=using&lr=lang_en The official MySQL site doesn't explain the USING command. Can you do that please? ...

How to create custom storage engine for MySQL?

Unfortunately Sun Microsystems behaving badly by removing the link to the article on how to create custom storage engine for MySQL. By any chance you have that article, or can point to another resources on the web that talks about how to create custom engine? This is 'dead' link ...

ORDER BY date while also using LIMIT in a MySQL query - PHP

HI, I can't quite figure this out, I'm trying to pull records from MySQL, order them reverse-chronologically and limit the results to four per page (and using pagination to organize the pages). It is currently returning this error: Fatal error: SQL in /Users/allan/Sites/4is_site/casestudylist.php on line 126 $limit = 'LIMIT ' .($pag...

MySQL - How To Avoid Repair With Keycache?

I have had some experience with optimizing the my.cnf file but my database has around 4 million records (MyISAM). I am trying to restore from a mysqldump but every time I do I eventually get the dreaded "Repair With Keycache", that may take days. Is there anyway to get past this and let it roll as "Repair By Sorting"? I have 2GB RAM, ...

Existence confirmation method of the table of MySQL

I want to confirm whether there is a certain table. When create a table, there is an SQL sentence such as DROP TABLE IF EXISTS xxx_tb. Will there be the method that can identify the existence of the table by SQL likewise? ...

Combine Multiple child rows into one row MYSQL

Thanks in advance, I just can't seem to get it! I have two tables Ordered_Item ID | Item_Name 1 | Pizza 2 | Stromboli Ordered_Options Ordered_Item_ID | Option_Number | Value 1 43 Pepperoni 1 44 Extra Cheese 2 44 Extra Cheese What I am looking to o...

Function to escape different variable types in MySQL Query

I got sick of writing queries in my PHP as: "WHERE '" . Database::escape($var) . "'"; The escape() function just calls mysql_real_escape_string() - but it's there so I can extend support to other databases later. Having to single quote strings in the query was making my code more cluttered. So my idea was to create an other function ...

Mysql SHA salt

Hello, I am setting a cookie something like: $_COOKIE['test'] = SHA1('124'.'mysalt'); Now 124 is my id which i want. So in my mysql table, I am trying to run a query like: $sql = ("SELECT * FROM users WHERE SHA1(`id`) = '".mysql_real_escape_string($_COOKIE['test'])."'"); Problem is how to do I add the "mysalt" to the sql query? Be...

Calling a field from database in MySQL

return(array($clientName,$salesPer,$prospectVal,$projID)); The projectID is dynamically added in database for each entry, now how can i return the ID. As i have not set any variable in PHP to map the database field. Can anyone guide me on this. ...