mysql-query

@ is not an in parameter in my mysql query

I'm running this query: LOAD DATA INFILE 'SomePath' INTO TABLE SomeTable FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' (column1,column2,@Column3Value) SET column3 = CAST(@Column3Value AS UNSIGNED); I'm using the @Column3Value param because this field is a bit type field and this is the only way to do a loading...

mysql select query return un related output

SELECT updateDate, id,cSsn,cLname,cFname,cDOB,cDOD,cCity,cState,cHospital,cCurstatus,cMmrcashworker,cTelephone FROM med_patient WHERE cCurstatus!='completed' AND cMmrcashworker = '2' AND cHospital = '1234' OR cHospital1 = '1234' OR cHospital2 ='1234' AND updateDate between '1/30/2010' and '1/28/2010' order by id desc' Output : updat...

mysql: query to return scores ranks according to a specific user

Hello. Lets say i have the following scores table (total rows of 10): rank userid score ---- ------ ----- 1 |455 |10 2 |435 |9 3 |354 |8 4 |342 |7 5 |343 |6 6 |123 |5 7 |125 |4 8 |128 |3 9 |5 |2 10 |6 |1 the user can fetch his score status, and he can get 5 score positions around hi...

How can i convert a price field which is currently varchar to a decimal so my prices will order correctly?

I am using MYSQL. I have a varchar field which i incorrectly used for a price. Now the ordering of this table will not work correctly putting anything over 1000 to the bottom of the list. I need to convert this price field in an existing POPULATED database from varchar to decimal i guess? Any help would be appreciated. ...

mysql: select max(score) doesn't return the relevant row data. how to solve the isssue ?

Hi. if i have for example a scores table: user game score timestamp 1 50 50 date 2 60 40 date 3 70 25 date 4 80 18 date and i run the query: select user, game, max(score), timestamp from scores i will receive the maximum score number that is 20, but the rest of the columns that ...

Please suggest how to achieve this with joins

I need to write queries to find out new users and regular users. new users are the ones whose uuid appeared in last 24 hours (from now minus the time query is fired) in table2 and was not there before. regular users are the ones whose uuid appeared in last day in table2 and was also there at least once in the last 3 days. In addition ...

mysql multiple limit in one sql statement

I have table in my DB called "students" contains the following columns (student_id, student_name, year_of_birth).and array of years I trying to make one query that gets 10 student_id of each year in (years) array. I could write SELECT student_id FROM `students` WHERE year_of_birth=1950 LIMIT 10; SELECT student_id FROM `students` WHERE...

MySql from Linux 64bit to Windows 32Bit - Slow queries?

We have a database that was backed up from a Linux 64 bit version of MySql that we have restored onto a Windows 32bit version of MySql. We have a table with about 4.5 gig of data - the main space being consumed by a BLOB field containing file data. The table itself only has about 6400 records in it. The following query executes on the ...

how to create shopping cart database tables and fetch the products from database.and display the products

using mysql and php programming .... ...

mysql sum different field derived from different tables

hi to all I want to sum different field came from table table. Here is illustration. Any help would greatly appreciated Thanks in advance Tirso maintable id name firstname date_created 1 john ko 2010/01/12 2 mhel sy 2010/01/15 3 johnson king 2010/01/16 4 venedict lee ...

MySQL query help

I really need some help with forming a MySQL query that I just cannot work out. On my website I have a system in place that will hopefully remember some selections that user made when they last visted the site. On the site the user can select which category they wish to read the content of next time they come to site. That setting will ...

MySQL FULLTEXT search

How do you add a column to a fulltext search in MySQL to indicate which words were included in the search? ...

Multiple criteria with count of matches

I have 2 tables, a table of people with peopleID and name, and a table of pledges they have made which has a pledgeID (1 to 6) a personID to say who it came from, and an amount field. We need to have a query that gives a distinct list of people, how much they have pledged in total, and the number of pledges they have got correct (pledge...

how do i display all the tags related to all the feedbacks in one query

Hi, I am trying to write a sql query which fetches all the tags related to every topic being displayed on the page. like this TITLE: feedback1 POSTED BY: User1 CATEGORY: category1 TAGS: tag1, tag2, tag3 TITLE: feedback2 POSTED BY: User2 CATEGORY: category2 TAGS: tag2, tag5, tag7,tag8 TITLE: feedback3 POSTED BY: User3 CATEGORY: cate...

Mysql subquery : Trying to get the last order from a customer

Sorry , maybe it's trivial but I can't find a way to do this : table customers customer_id customer_email customer_newsletter (1=yes/0=no) table orders order_id customer_id order_status (1=ok/0=no_ok) Each customer can have zero, one or many orders. I'm trying to make a query to get all the emails of the persons who are : ...

MySQL query caching: limited to a maximum cache size of 128 MB?

My application is very database intensive so I've tried really hard to make sure the application and the MySQL database are working as efficiently as possible together. Currently I'm tuning the MySQL query cache to get it in line with the characteristics of queries being run on the server. query_cache_size is the maximum amount of data...

Search problem in mysql query

Hi I have some problem regarding the search in mysql. Below is my query. SELECT * FROM table WHERE name LIKE "%admin\'s%"; When i am executing this query it will return zero data. actually i have "admin\'s" stored in db. this "\" is to prevent sql injection. i have used mysql_real_escape_string to prevent the sql injection. but wh...

SQL: How to select elements in a rectangle range from a large continuous matrix? **UPDATED**

I'm having a hard time working out the following problem efficiently. I have a 15000x15000 xy matrix. I'm storing element locations in this matrix by defining a x,y coordinate for the element. I want to display a part of the matrix in a so called viewport. The viewport dimensions are e.g. 1600x1000 Consider the following db structure: ...

Ordering by the first alphabetical char in a column in MYSQL

A table in a MYSQL database has address details- eg... add1, add2, add3, district, postalTown, country Ordering by postal town is usually fine, but some details have numbers in the postalTown column. For example 1420 Territet or 3100 Overijse. This will mean these will appear at the top above Aberdeen or Bristol. Is there a way of order...

Selecting a specific Date Time from a datetime field in MySQL

How can this be done properly in MySQL? I want to select records that are created after a specific date AND time... I thought something simple like this would do the trick, but I think it needs a bit more to it to work. SELECT `modified` FROM `Blog` WHERE `modified` > 2010-01-08 16:01:01 Any help appreciated. ...