mysql

if function inside sql query?

function get_tags_by_criteria($gender_id, $country_id, $region_id, $city_id, $day_of_birth=NULL, $tag_id=NULL, $thread_id=NULL) { $query = "SELECT tags.* FROM tags, thread_tag_map, threads WHERE thread_tag_map.thread_id = threads.id AND thread_tag_map.tag_id = tags.id AND threads.gender_id = $gender_id ...

Mysql Fulltext help

I am using this to search my table: if ($querystring!=''){$query_cont .= " AND MATCH (headline) AGAINST ('$querystring')"; } Thing is, in the 'headline' field I have a value of say 'BMW'. Then when I enter BMW in the search field, that is "$querystring = 'BMW'", no results are found. I have set the index of the 'headline' field to ...

PHP/MySQL - SQL syntax error?

Now when I submit the character ' I get the following error listed below other then that everything is okay when I submit words. I am using htmlentities() and I still get this error. How can I prevent this error from happening is there a way I can allow or convert or stop the character ' form displaying as an error? Here is the error I...

How to change 'ft_min_word_len' in WAMPSERVER ?

I can't figure out where it is located. I only find a 'my.ini' file which doesnt have a 'mysqld' section in it... Do I have to upload my website to an ACTUAL server before attempting this? Thanks ...

Adding multiple textbox entry to a mysql database

I have created a form, with 5 textbox fields and I want to add those five entries in the database. I want to use the textbox "array", that way I can use a for-each when saving to the database. As anyone, any code on how to do this or can direct me in the right path? input type="text" value="whateva" name= ?php text[0] ?> input type="te...

why can't I find my.cnf?

I did updatedb. I did locate my.cnf But I cannot find it? Nothing. (I installed MYSQL using aptitude install mysql-server, and mysql does work right now.) ...

Generating report with MySQL and Rails - how?

Here is my data model from my application: id :integer(4) not null, primary key spam :boolean(1) not null duplicate :boolean(1) not null ignore :boolean(1) not null brand_id :integer(4) not null attitude :string not null posted_at :datetime not null Attitude could ...

Display a leading item then follow with addtional items alphabetical

Is there a MYSQL or PHP method to display an item first before all others then display the rest of my items alphabetically? SELECT client_name FROM clients ORDER BY client_name ASC Gives me the following list: Bob Harold Sandy Timmy Except I am looking for a way to display them in order like this. Harold Bob Sandy Timmy or lik...

How can I make an index that multi column as one index's column?

say, I have a table TABLE(col1,col2,col3) and, I want create a index INDEX(col1=table.col1+table.col2) ...

Split up a mysqldump file with multiple databases, by database

Hello, I have a mysqldump file of multiple databases (5). One of the database takes a very long time to load, is there a way to either split the mysqldump file by database, or just tell mysql to load only one of the specified databases? Manish ...

MySql Question - way to update portion of a string?

I'm looking for a way to update just a portion of a string via mysql query. For example, if I have 10 records all containing 'string' as part of the field value (i.e., 'something/string', 'something/stringlookhere', 'something/string/etcetera', is there a way to change 'string' to 'anothervalue' for each row via one query, so that the...

A database question for storing and computing with historical data.

I have an application that polls different bins at different times and computes the number of widgets in each bin based on the weight. Polling is done every few minutes and the result is timestamped and added to a MySQL table. The table contains the 3 columns below. The example shows 3 bins (A,B and C) but there could be anywhere from 1 ...

PHP/DB pattern question

I have an app that works with an idea of "redemption codes" (schema: ID, NAME, USES, CODE). And example would be "32, Stack Overflow, 75, 75%67-15hyh" So this code is given to the SO community, let's say, and it has 75 redemptions. You redeem it by entering some shipping info and the code. When entered, this check is preformed: if (cod...

mysql_fetch_assoc returning results in the wrong order

Hi, I have the following code: $sortorder = $_GET['sort']; switch($sortorder) { case "modulea": $result2 = db_query("SELECT * FROM {vanqueue_registrations} WHERE isactive=1 ORDER BY `cleanmodule` ASC"); case "moduled": $result2 = db_query("SELECT * FROM {vanqueue_registrations} WHERE isactive=1 ORDER BY `cleanmodule` DESC")...

mySQL ORDER optimizing

I have a query in which I am ordering a league table by a number of fields to handle the situation that some fields in the result may have the same value. I am curious as to why when subsequent fields aren't required for secondary ordering the query is still conciderably slower. Case in point is a table of items that are voted on. It co...

Web page installer - database deployment

I have the website written in PHP (Kohana) and MySQL. I want to create the installer which would run all the environment tests and, what is the most important (and the most misterious) for me, will deploy the database. What is more, I would like to choose the prefix of the tables in the database and specify the username and password for ...

How to fill date gaps in MySQL?

How i can fill date gaps in MySQL? Here is my query: SELECT DATE(posted_at) AS date, COUNT(*) AS total, SUM(attitude = 'positive') AS positive, SUM(attitude = 'neutral') AS neutral, SUM(attitude = 'negative') AS negative FROM `messages` WHERE (`messages`.brand_id = 1) AND (`messages`.`spam` = 0 AND `mess...

How to escape quotes "" characters in mysql and java

How can we escape quotes "" characters in Java and MySQL? Incoming xml file has quotes and am parsing through that file using java and so i want to escape quotes here but in database it should contain quotes and while am doing query the result would have quotes and while displaying on webpage also it should show quotes. Hope am making m...

AES, MySql and Headaches

Hello everyone. I am working on a checkout page for an ecommerce site. In said site, people input their credit card information and it is saved to the order in an AES encrypted format. This worked fine when all they supported was VISA. Now that they support MasterCard and Discover (16 digit numbers), it no longer works. The insert q...

MySQL Query Question.. I give up!

*UPDATE, seems like the answer was given, but the SQL query his erroring out.. can anyone help? See the first answer, i posted the problem there. So to put this simply. I have 3 tables. An "item" table and a "tag" table. Then I also have an "item_tag" table which ties the 2 together. I want to make a query that lists all the items ...