mysql

Syntax Error with MySQL Query

Hey everyone, I am getting the following error and I have spent hours looking at it and cannot figure out why! ERROR: 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 'primary='doej2', secondary='1' WHERE id='2'' at line 1 Here is my code: <?php if (...

MySQL: DATE_ADD

Is there a difference between: SELECT DATE_ADD('2005-01-01', INTERVAL 3 MONTH); and SELECT '2005-01-01' + INTERVAL 3 MONTH; ...

expiry date using utc timestamp, mysql and php?

How do you add time or days to a current utc_timestamp? I am using; new CDbExpression('UTC_TIMESTAMP()') for both 'created' and 'updated' fields in my mysql table but would like to add an 'expiry' field which would allow 4 days from creation date. I presume this is possible but am unsure how. Thanks ...

MySQL: Merge 2 tables for a SELECT query?

First.. here are the two tables I've created (sans irrelevant columns).. CREATE TABLE users_history1 ( circuit tinyint(1) unsigned NOT NULL default '0', userh_season smallint(4) unsigned NOT NULL default '0', userh_userid int(11) unsigned NOT NULL default '0', userh_rank varchar(2) NOT NULL default 'D', userh_wins int(11) NOT ...

MySQL conditonal query inside where clause

I'm not sure if I'm missing something really obvious, but I keep getting a syntax error on this query. Even if I AM missing something obvious, I'd like to know if there is a smarter way of getting what I'm after. Basically, the query asks for any rows tied to a user with a start_date between Monday and Friday. That works great. But then...

calling stored procedure with output parameter

Herewith I have given the stored procedure "GetAvgOut": delimiter // DROP PROCEDURE IF EXISTS GetAvgOut// CREATE DEFINER = 'MailIntimator'@'127.0.0.1' PROCEDURE GetAvgOut(OUT average INT,IN col VARCHAR(30),IN tbl VARCHAR(30)) READS SQL DATA COMMENT 'returns average' BEGIN SET @userVar = CONCAT(' SELECT AVG( ' , col , ' ) FROM ' , tbl );...

Is storing URL-encoded text in the database a good idea?

I need to store (possibly long) text in a MySQL database. The text may contain special characters and non-latin letters and it should be possible to perform full-text-search on it. MySQL 5 can't store such characters (but it will be possible in MySQL 6), so I though about URL-encoding the text before storing it and decoding it after fetc...

Annoying PhpMyAdmin export feature

I wonder if any other users of PhpMyAdmin for Mysql have come across this niggle? Normally when exporting the results of a sql query, you're given options (eg what format to export in , name of filename etc). However above a certain number of rows, these options are not available and you can only see the sql on the normal window. Obviou...

Update command not working properly in PHP

$query = "UPDATE members SET userrole ='$userrole' WHERE member_id = '$member_id'"; Sometimes it updates and sometimes it does not... i don't know whether the syntax is correct. userrole and member_id has array of values. The update query is performed for multiple items being checked. There is no error in mysql connection or error......

What is Mysql Link ?

Hello I am debugging a php application. In the Local Debugging window, it shows the following information Name value Type LinkID 15 mysql link The value of LinkID change within the program What is mysql link type , being shown in the debugging window? Also, can anyone explain what the function performs ? Here is the...

Shipping MYSQL Dabatase with product

Can anyone help me understanding what can I do if I want to ship a MYSQL database along with a web based software I have. I am using a free version of MYSQL 5.1. All I want is the client should not able able to get the access to my database/tables, but my application should be able to access database when installed on the client machine....

Delete command Issue in PHP

I have a similar problem with delete command too.. function deleteUsers($userID) { foreach($userID as $key => $val) { $query = "DELETE FROM members WHERE member_id = '$val'"; $result = mysql_query($query); } //$query = "DELETE FROM members WHERE member_id = $userID"; //$result = mysql_query($query); ...

Mysql Storing Serialized Array

Hi, I have 3 Tables: Regions Table which has 1500 Towns in it. Categories Table which has 1800 categories. Companies Table containing businesses. What I need to do is grab a town, for example Brimingham and list in an Array which categories have businesses using our main Companies Table, so we don't have any categories stored in the...

how to make working for full text seach for 3 characters

Hi! I have used full text search mysql. My code is select * from uh_property WHERE match(fieldname) against('serach_word') Now when i type word of three character search record is not displayed. For example i have record with name 'eco'. When i type eco in text box for search no record displayed. I found that minimum characte...

Connecting to MySQL with PHP

I have MySQL running such that I can open a client command line and log on and make databases, tables, etc. I wanted to do some AJAX. Doing AJAX with ASP, SQL Server, etc is not advisable since both places where I am hosting my websites do not use the Microsoft products. So I am forced to do my development with PHP and MySQL. I just ...

"order by" taking too much time in mysql

"order by" in query is taking to much time in MySQL. SHOW PROFILES shows that the time is taken by the sorting process. Is there any setting/workaround that will decrease the sorting time ? ...

How are regular and composite indexes implemented in RDBs?

In databases like MySQL or Oracle, how are indexes implemented? I think regular indexes are stored as B-trees, but couldn't find anything about composite indexes that index on multiple columns. I'm looking for the names of the data structures used so I can research them. More generally, where can I find more such information about datab...

What datatype is suitable for storing latitudes and longitudes?

what should be the data type of latitudes and longitudes in general ...

programmatically replace SELECT fields in sql query to determine number of results

Given any query (grouping, joins, and subqueries are all possible in any combination), I'd like to break it up with pagination as efficiently as possible. Right now I just run the query, then count the number of rows returned to PHP, figure out how many pages of data that is, display the ones that go on the current page, and output the p...

SQL CODE to do: Trending topics equals a twitter

If i wants count the matching words in a rows of two tables, with milions of rows, sample: Table posts, sample: +----+---------+-----------------------------+ | ID | ID_user | text | +----+---------+-----------------------------+ | 1 | bruno | michael jackson is dead | | 2 | thomasi | michael j. moonwalk...