mysql

can i apply mysql partition on this table ?

Hello all I have this table CREATE TABLE IF NOT EXISTS `posts` ( `id` int(10) unsigned NOT NULL auto_increment, `thread_id` int(10) unsigned NOT NULL, `forum_id` tinyint(5) unsigned NOT NULL, `cat_id` tinyint(3) unsigned NOT NULL, `message` mediumtext collate utf8_unicode_ci NOT NULL, `userid` int(10) unsigned NOT NULL, `...

mysql: take all records with meeting_id = x and it's parent is available but don't care if available itself ?

how do i select all records matching following criteria: take all records with meeting_id = x AND it's parent is available OR doesn't have parent but don't care if available itself ? table people: id, name, address, meeting_id, available, parent_id ...

can I combine these 2 simple queries into one query?

select count(distinct id) from svn where name='ant' and type='Bug' and select count(distinct id) from svn where name='ant' and type='Feature' Is it possible to combine them into a single query that might reduce the execution time compared to running them individually? Thanks for answering. ...

Autoincrement problem mysql

I've looked for this but no luck so far. I have two tables in mysql, they are configured as parent-child. The parent table has a field of type auto_increment, and the child has a field that references the autoincrement column in the parent. When I do inserts into the parent table everything goes fine. But when I do insert on the child ta...

Returning JSON from a PHP Script.

I want to return a .JSON from a PHP script, do I just echo the result? Do I have to set header content-types? Any help would be great! ...

Starting mysql in new EC2 instance throws "can't connect through socket" error

I have an ec2 instance, but when i run mysql, it gives me this error ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Similarly, when i run /etc/init.d/mysql start Oct 31 11:29:16 domU-12-31-38-00-A8-62 /etc/init.d/mysql[5263]: error: 'Can't connect to local MySQL server throu...

Frinds table for a social network website

Hello, Now i am working on a social network website and i already built the friends table for this website but i need some suggesion before i moved forward. I have a user table where user_id is the primary field. So for frinds i made a friends table with fields like friend1,friend2,is_active what i do actually when user1 send a frie...

How to install mysql2 gem using bundler and capistrano

I'm trying to deploy a small rails3 app to a FreeBSD host using capistrano and bundler. I have added the line require 'bundler/capistrano' to my deploy.rb file, and bundler seems to work fine until it comes to the mysql2 gem. Here the install fails because the install script uses chmod and chgrp to try to install the gem with root:whe...

MYSQL enumeration: @rownum, odd and even records

Hi, I asked a question about creating temporary/ virtual ids for query results, http://stackoverflow.com/questions/4063998/mysql-php-temporary-virtual-ids-for-query-results/4064066#4064066 I nearly got I wanted with this link, http://craftycodeblog.com/2010/09/13/rownum-simulation-with-mysql/ I have managed to enumerate each row, SEL...

Find missing rows using SQL

I have an SQL table as such name | engins| frank ---------------------------+-------+------ John Smith | 8422| 854 (1 rows) And need to make a query such that only return the row john smith when engins is more than 2000 ...

selecting items that come after a specific value

Say this is my sql: SELECT title, author, ISBN FROM bs_books ORDER BY ISBN LIMIT 3 It just selects everything from a certain table (title, author, etc..). Say I would like to select all the items that come after a certain title, not alphabetically or something but just the records after the certain elem...

how to allow your code to store undetermined number of columns ?

Hi, I think my question might be unclear , but i would try to explain it by example . say that we had about 100 different car model , clearly all of the car would share common parts or specification but not all parts are shared between all of these 100 car brands what is the best practice of storing these specification in this case...

How to select 3 of each results for given catids in mysql

This may be a tough one for you all, if it is even possible in mysql. I have a table that stores id, catid, product_name What i would like to do is select 3 records for each catid then display the result with each 3 sets of records first. So if i have a catid of 4, 7 then I would like to display 3 results for (4) then 3 results for (7). ...

SELECT in mysql

Possible Duplicate: selecting items that come after a specific value i asked this allready bu explained it very bad so i'm gonna do it right this time. I have a mysql table like this: ISBN title author price amount 978-0060850524 A Brave New World Aldous Huxley 6.49 7 ...

php /mysql coding not working

i seem to be having an error on this coding any help would be appreciated Parse error: parse error in C:\wamp\www\espn.com\login.php on line 19 <?php //Database Information $dbhost = "localhost"; $dbname = "users"; $dbuser = "root"; $dbpass = "*****"; //Connect to database mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could no...

Order by field mysql command doesn't work, gives wrong order

Hi. I have a strange problem. I tried this command in mysql: SELECT `type`, `bought` FROM cars WHERE owner = 'test' ORDER BY type And it prints out this in phpmyadmin: type bought -------------------- 17 1281025497 22 1287708417 22 1287347244 24 1287708324 24 1287876461 6 12878...

Store the order of something in MySQL

Let's say I have a table that's like the following: name VARCHAR(50) PRIMARY KEY NOT NULL ordernum TINYINT UNSIGNED NOT NULL Also let's say I have 3 rows. something - 1 somethingelse - 2 somethingmore - 3 If i want to insert another entry called something1, and give it an ordernum of 2, how do I reorder all the rows that has an...

Selecting online users from db with mysql command

Hi. I use this code to update the user database with the latest time when the user was online: $postTime = $user_array['last_online']; if ($postTime == ""){ $minutes = 11; } else { $now = time(); $seconds = $now - $postTime; // $seconds now contains seconds since post time $minutes = ceil($seconds / 60); // minutes sin...

What is the best Relational Database Management System (DBMS) to use with a web app?

It seems like most people use MySQL together with PHP. I've used H2 and Postgres with Java, but I can't really say why, I didn't evaluate any before I started. Does some work best with a specific language? Are there more stable ones that are better at large capacities? ...