mysql

How to Set a Value to NULL when using Zend_Db

When performing UPDATE and INSERT queries using Zend_Db, I frequently need to set values equal to NULL (not ''). However, the default behavior of Zend_Db::insert() and Zend_Db::update() seems to be that values that are empty are translated into empty strings ('') and put into the database as such. Does anyone know of way to actually fo...

How can I get the most popular words in a table via mysql?

I've got a table with a BLOB collum. What I want to do is get it to be able to pick out words and list them in order. For example if it contained: Bob Smith likes cheese but loves reading Charlie likes chocolate milk Charl loves manga but also likes cookies Then I would get likes loves as a result... is this possible and if so h...

Problem displaying the mysql content in Paragraphs

Hello, I insert questions(which might be a few paragraphs) in a sql table using php and than i diplay them on a webpage. but when i display the question it loses its formatting. I mean it will just show the whole question in one paragraph, even thou there were many paragraphs before. <td width=\"700px\" bgcolor=\"#EAD57F\"><font co...

Most efficient way to get lists?

What's the best way to get a sublist of things? I have two tables: create table A ( id int primary key ) create table B ( id int primary key, aid int foreign key references A( id ), sort_key int ) I want to get a list of objects A, with subobjects B, but only the top five of B. Let's say A is people, and B is type of food, ...

length of column across all tables in a MySQL Database

How to get the max column size of common column like 'id' across all tables in the Mysql ...

MySQL Join Condition

I'm having trouble thinking of a way to do the following join in MySQL. I'm not sure which joins would be best suited for this task, so I'll edit the title when someone points it out. Here's the gist of what I'm trying to do. I have two tables, call one Students, and the other Marks. They are setup as follows, Students Only the Id ...

MySQL View check if data is NULL

I need to put a Case in the Select to check if the Data I'm adding to my view is NULL, in which case I want it to just enter a zero, or not. ...

When INSERTing into a table can I get the value of the automatically incremented primary index?

I am inserting a row into a table and would like to get the value of the automatically incremented primary index. The primary index is the only unique value in the table so I don't want to do anything like "SELECT [primary index] FROM [table] WHERE [the columns = the data I just inserted]" to prevent ambiguity. I also don't want to SELE...

How can I optimize this query to execute faster?

This is for the friends module on my site, where users can make friends with each other. These are stored in a "friends:" table, with person who initiated the friendship being the friendship_inviter and the person on the approve/deny end of things is the friendhsip_accepter SELECT user_id, user_name, user_gender FROM friends LEFT JOIN u...

Joining and searching multiple MySQL tables with one-to-many relationships

I've been furiously googling trying to figure this out, with surprisingly little luck; I would guess this is a common issue. I have 5 tables: orders, addresses, notes, transactions, line_items, and shipments. transactions, addresses and notes all have indexed order_id fields - line_items and shipments have indexed transaction_id fields...

need help with mysql joins

Users table user_id pic_url name friends table auto_id userid friendid status actions table auto_id userid type subject body datetime I want to make a friend stream of updates thats shows updates, could be a blog post, status change, anything but should only show the ones that are from a friend of the logged in user Her...

How to perform this task in 1 single, efficient mysql query?

I have a list of TV shows stored in 1 table. Another table stores show genres (action, romance, comedy). Most shows usually have more than 1 genre, so having a single tv_genre column and putting the genre ID in there isn't an option. I could create a look up table which would store tv show id + genre id, and I could insert 1 row for e...

Trouble getting MAMP to work with PDO-MySQL

Problem: Doctrine test application isn't working because of driver issue. Setup: Mac OS X 10.5.7 (not server), MAMP 1.7.2, Doctrine 2.2.1, PHP 5.2.6 I am following the doctrine documentation to try to set up a development environment on my local machine. The output of running the page from the web (through MAMP) shows an empty screen (...

mySQL Query Browser connection using ssh

Does anyone know if there's a problem with the mysql query browser using connections over SSH on the Mac? I use the command: ssh -L33306:localhost:3306 user@host then I try to open a connection with the MQB pointing it to localhost port 33306 I get an error "Could not connect to MySQL instance at localhost..." What's odd is that this ...

what are my options as my mysql DB grows

How could I improve this query? Please tell me all my options here as my social network DB is only getting bigger This Query took 2.1231 sec SELECT friend_friend.friendid, friend_reg_user.disp_name, friend_reg_user.pic_url, friend_reg_user.online FROM friend_friend INNER JOIN friend_reg_user ON friend_friend.friendid = friend_reg_user...

Rails application deployed and working, but MySQL database appears empty

I've deployed a Ruby on Rails application using mod_rails and nginx over Capistrano, and it's working perfectly, but I have a baffling problem. When I run the following command on the server: SHOW TABLES IN application_production; MySQL returns: Empty set (0.00 sec) I know that information is being written to the database because ...

Count line breaks in a field and order by

I have a field in a table recipes that has been inserted using mysql_real_escape_string, I want to count the number of line breaks in that field and order the records using this number. p.s. the field is called Ingredients. Thanks everyone ...

Optimizing php command line scripts to process large flat files

I have a large flat file that I need to process in php. I convert the flat file into a normalized database in mysql. There are several million lines in the flat file. I originally tried to use an ORM system while importing the flat file. There was a massive php memory leak problem with that design even with careful freeing of objects. E...

Subsonic 3 and Activerecord isn't generating MySQL Stored Procedures

It seems that the included T4 templates (or the one in the SVN trunk for that matter) just skips generating SPs for MySQL... When running StoredProcedures.ttinclude together with MySQL.ttinclude, I get the error "Compiling transformation: The name 'GetSPs' does not exist in the current context". GetSPs is defined for SQLServer and I saw...

How to change the set of characters that are considered word characters in Mysql (Without recompiling)?

Hi, I run a Mysql 5.0.26 (Myisam tables). To improve the search results, I am doing some fine tuning. I have noticed that the characters considered as word characters do not match the constraints of (Swiss-) French... and English too. :( I would like to: ADD the character "-" in the "word character" list REMOVE the character "'" from...