mysql

How can I merge two MySql tables?

How can I merge two MySql tables that have the same structure? The primary keys of the two tables will clash, so I have take that into account. ...

Display database contents? PHP / MySQL

So I have a chatroom type of database where the text that a user inserts gets stored into a databse as their username in one field and their message in the other. I want to have my page output the database info, so that people can see each others messages. How do I do this? Also, is it possible to make a for loop that checks to see if ...

What is the difference between a Provider and a Connector in database world?

I create an new text file, rename it to test.udl and double click on the file. This brings up the OLE DB connection string dialog box. The first tab shows a list of providers installed on my machine. I need a MySQL Connection string, but I do not have a MySql provider in the list. So I download MySql ADO.NET Connector from the internet a...

Default sort-ordering in MySQL (ALTER TABLE ... ORDER BY ...;)

Assume that the default ordering of a MySQL-table (ISAM) is changed by executing: ALTER TABLE tablename ORDER BY columnname ASC; From now on, am I guaranteed to obtain records retrieved from the table in the order of "columnname ASC" assuming no "ORDER BY" is specified in my queries (i.e. "SELECT * FROM tablename WHERE ... LIMIT 10;")...

Connecting to MySQL database with PHP

I have this little function do connect to a MySQL database: function connectSugarCRM() { $connectorSugarCRM = mysql_connect ("localhost", "123", "123") or die ("Connection failed"); mysql_select_db("sugar5") or die ("Failed attempt to connect to database"); return $connectorSugarCRM; } And then, to run a query, I'm doi...

Empty database in MySQL and PHP?

Is it possible to empty an entire database by connecting to it with PHP and giving a command? ...

Clear data in MySQL table with PHP?

How do I clear all the entries from just one table in MySQL with PHP? ...

mysql query, reuse columnnames in query

I have a mysql query, something like this: SELECT users*100 as totalusers, totalusers*90 AS totalsalerys FROM table As you can see I want to reuse the totalusers when calculating totalsalerys so I son't have to write the same code again. That dosesn't seem to work in mysql, is there another easy way to do this? My query is just an ex...

mysql + update top n

I've got a query like this: update table set status = 1 where status = 2; but I'd only like to do this to the top 400. I tried adding a 'limit 0, 400' (like I would in a query) but that didn't work. I did some searching and mysql doesn't seem to support the TOP(n) command as sql server does. Any idea how I'd do this? edit: fo...

MySQL Query to create a "bump-system" for a forum I am making

Hello, I'm having trouble forming a MySQL query that performs the following action: Select all threadIDs from the threads table ordering by the timestamp (in descending order) of the most recent post (largest timestamp) with threadID equal to the threadID of each thread. So basically I want to go through the threads and have MySQL check...

Should a single-row summary table have a primary key?

Say you've got a summary table that's meant to have only one row (storing a row of statistics about another table). In this case I'm using InnoDB so that I can update it as well as the table it's meant to contain a summary of transactionally. Should I make this table have a primary key? If so, what, just a tinyint that's always equal to ...

How to efficiently unpublish all datas from a particular user on a blogging application ?

We develop and operate a blogging application in which user data a scattered across many tables: - Blog - Article - Comment - Message - Trackback - 50 other tables. Users are able to close their account, and their account/contents must disappear from the site right away. For legal/contractual reasons, we also must be able to undelete...

What kind of file is this?

I don't known the full story as I just got involved recently but I have a file that is "a MySQL data base" (longish story, the source is not technical). The file name is: something.db the Linux file command just gives data looking inside I find Copyright (c)2000 9.0.0.1108 Sybase (might be an author or file format vendor) I'm suppose...

Codeigniter: MySQL where clause, and quotes

Here's my query in Codeigniter: $this->db->select('comments.created_at, comments.section_id, comments.submittedby_id, users.username, comments.text, sections.name'); $this->db->order_by('comments.created_at', 'desc'); $this->db->where('comments.submittedby_id', 'users.user_id'); $this->db->where('comments.section_id', 'sections.id'); ...

MySQL set storing

I have a couple of tables in a web application I'm coding in PHP, and I would like to know if this would be good pratice. CREATE TABLE `products`( `product_id` int NOT NULL auto_increment, `name` varchar(255) NOT NULL, `variations` varchar(255) default NULL, PRIMARY KEY (`product_id`) ) CREATE TABLE `variations`( `variation_...

How do I use a Rails ActiveRecord migration to insert a primary key into a MySQL database?

I need to create an AR migration for a table of image files. The images are being checked into the source tree, and should act like attachment_fu files. That being the case, I'm creating a hierarchy for them under /public/system. Because of the way attachment_fu generates links, I need to use the directory naming convention to insert ...

Should I use MySQL 6.0 for my large project?

MySQL 6.0 is for production. Can I use it for database storage of a large project? ...

Should I use a single procedure for multiple operations, or split them into multiple procedures?

I am writing stored procedures for several operations in a database, I just wanted to know: Is it better to design a single procedure for a table which can perform add, modify, delete operations or... Should I design seperate procedures for each operations Which approach would be better? ...

Java and MySQL date problem

Hi I do a rs.getTimestamp("datetime") in Java. In the database, this datetime is 2009/03/06 02:47:18 but the time is returned as 14:47:18 I'm not very knowledgeable about MySQL dates, so I would appreciate any explanation as to why this is happening. ...

MySql Stored procedure creation Error

I am trying to create a stored procedure in my mysql database usin the below code.I am getting an error.Please help me to solve My MySQl version is 5.0.51b CREATE PROCEDURE tv_insert_user(IN firstName VARCHAR(25), IN lastName VARCHAR(25), IN emailId VARCHAR(22),IN countryId INT,IN stateId INT) BEGIN INSERT INTO tv_user_master(FI...