mysql

How does MySQL store timestamps internally?

How does MySQL store timestamps internally? Is it an int, or a string or something else? ...

Doublet select/delete in mysql database

Hi everybody ! Here is my question : I have a database (mysql) like this : id0 id1 id2 And i would like to delete the lines who have the couple (id1,id2) in common to keep only one. Example : 1/1/1 2/1/2 3/1/2 <= Delete 4/2/1 5/2/3 6/2/3 <= Delete I hope this is clear enough for you to help me :) Thanks ...

Use select query inside the Insert query for the same table name

Hi Friends, Is it possible to use a "select" query inside the "Insert" query, But the condition is i want to use the same table name for both "select" and "Insert" query.For Examplemysql> insert into sample_elements (name,position,ownerel) values ('Namespace1', select id from sample_elements where name='Namespace1',0); Please guide me o...

help with php FOREACH loop

hi, can some please tell me what's wrong with the bellow foreach php loop. foreach ($_POST[sortlist] as $key => $value) { $sql = "UPDATE sortable SET color_order = " . mysql_real_escape_string($key) . " WHERE id = " . mysql_real_escape_string($value); $result = mysql_query($sql) or die(mysql_error());...

Page Views counter using PHP and MySQL?

I was wondering how can I alter my code so it can count the page views for each page when multiple pages are present and display the correct page views for each page. Here is my php code below. //Adds one to the counter $mysqli = new mysqli("localhost", "root", "", "sitename"); $dbc = mysqli_query($mysqli,"UPDATE counter SET counter =...

How to drop unique in MySQL?

Create Table: CREATE TABLE `fuinfo` ( `fid` int(10) unsigned NOT NULL, `name` varchar(40) NOT NULL, `email` varchar(128) NOT NULL, UNIQUE KEY `email` (`email`), UNIQUE KEY `fid` (`fid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 I want to drop the unique key on email,how? ...

DB schema question, products types

My question is how to model transactions for different types of products. So there is a Transactions table: TransactionId(pk) Amount Method AuthorisedBy(fk) And there are different tables for different types of products. Books table: BookId(pk) Name Description Price And a Pens table: PenId(pk) Color Description Price And a tab...

Securely Connect MySQL via PHP in ActionScript 3 using AMFPHP framework

My Flash movie would like communicate with MySQL server to fetch and save data between MySQL and SWF. I know AMFPHP can help with the communication, but is there a secure way to encrypt the texts sending between 2 sides (other than hashing password in MD5)? As far as I know, by default, AMFPHP sends out data in plain text. Also, I heard...

Page View Counter like the one here on StackOverFlow?

What is the best way to implement the page view counter like the one found here on this site where each question has a "Views" counter using PHP and MySQL?? ...

How to get the max of two values in MySQL?

I tried but failed: mysql> select max(1,0); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0)' at line 1 ...

Oracle Database Link - MySQL Equivalent ?

Oracle's database link allows user to query on multiple physical databases. Is there any MySQL equivalent ? Workaround ? I want to run a join query on two tables , which are in two physical databases. Is it possible in MySQL ? ...

MySQL MAX_JOIN_SIZE Error! Need to optimize query.

I run this query: SELECT u.user_id, u.fname, u.lname, n.title, n.news_id, n.post, n.zip, z.city,z.state_abbr FROM yc_users u, yc_news n, yc_zipcodes z WHERE u.user_id = n.user_id AND n.zip = z.zip ORDER BY n.stamp LIMIT 10 And get this error: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BI...

how to query date field between two days in mySQL

I know how to do it in Oracle, but I can't find same function in mySQL. try to google it..but can't find it. I have a table, there is a field name "create_date" , attribute is datetime so field value format looks like "2009-09-25 11:48:24" Now I want to add date condition , I want to find create_date between 2009/09/01 to 2009/10/14 m...

Sorting nearest date with MySQL

I have a simple task list which contains amongst others a title field and a deadline field. Some tasks got deadlines, other don't. Deadlines are simply stored with a MySQL date type. But the tough part (for me anyway) is to sort the tasks in the correct order: Ascending deadlines The rest (maybe by ID, but not important) Current que...

Trying to "add" one column to a table via SQL JOIN

I want to join two tables together and have ONLY the data in Table 1 (but every record) and add the data from a column in the other table if applicable (there won't be a match for EVERY record) I tried using a LEFT JOIN matching four columns but I get doubles of some records. If there are 1050 records in table 1 I want 1050 records ret...

Is "SET CHARACTER SET utf8" necessary?

Hi all! I´m rewritting our database class (PDO based), and got stuck at this. I´ve been taught to both use SET NAMES utf8 and SET CHARACTER SET utf8 when working with UTF-8 in PHP and MySQL. In PDO I now want to use the PDO::MYSQL_ATTR_INIT_COMMAND parameter, but it only supports one query. Is SET CHARACTER SET utf8 necessary? ...

Mysql SELECT help please

Hi. I have a querystring that contains a search string entered by the user. I want to search 2 fields in my table (description and headline) for the querystring.. Simply, I want to check both fields if any of the, OR BOTH, contains the querystring... I am using PHP by the way... SELECT * FROM db WHERE xxxxxxxxxxxxxxxxxxx? Tha...

mysql SELECT continued help please

Hi again... SELECT * FROM db WHERE description LIKE '$string' OR headline LIKE '$string' My problem is that the $string variable must be exactly the same as one of the fields in order to work... But I want just a part of the field to be the same as the $string... How can I do this? Thanks again... ...

Do you need triggers on a mysql database slave?

Say you are running two mysql servers: one a master, the other the slave. The master has triggers set that update columns with the COUNT of the number of rows in other tables. For instance, you have a news table and a comments table. News contains an INT column called "total_comments" which is incremented via trigger every time a new ...

mysql - user item ratings, 1 rating per user, updateable - table structure?

I'd like to give my users the ability to rate each item on the site from 1 to 5. They also must be able to go back and revise their rating for each item as they please. Lastly, the item's page will display the average-to-date of all user ratings when viewed. As for the PHP, I think I can handle that. What I'm struggling with is envision...