mysql

Simple SELECT query problem...

Hi, I have this MySql select query which seems to have a bug but I am quite "green" so I simply cannot see, so maybe you could help? Here is the query: SELECT node_id FROM rate WHERE node_id='".$cat_node_id_string."' LIMIT ".$node_count_star.",".$node_count_end." ORDER BY SUM(amount) GROUP BY node_id Thanks for help in ...

[MySQL Query] How to limit date?

I'd like to select all entries from a table where date is the last one and only those ones. For example: today is May 16th, the last entries I have from my table is dated from May 15th, but I have older ones (May 14th, May13th, etc). I'd like to select only the dated from May 15th, but it's not this specific date, I need to select every...

SQL string replace with ID statement

Is it possible to create a sql statement to do the following: Table 1 lists all of the drug names, Table 2 contains all of the side effects. Table 3 contains all the drug names by ID and all of the side effects separated by |. Is there some kind of SQL query I can run to re-create Table 3 where the side effects separated by | are the ...

do I store long strings in tables or in a separate text file?

Hi guys, I have a table where fields are 40 varchars long, but from time to time I would have to store text ( 250-1000 characters long ) there. What would be the best solution, to try and fit it into the table or just make a separate text file associated with each table? Thanks! ...

MySQL Query - Alternation of WHERE IN

I have a mySQL query which takes 3-4 minutes to be executed. It is a large database. This query uses WHERE IN to find the rows.. So, is there any alternate query/clause/statement for my this query? (shortened and formatted version below) SELECT r.reg_id, r.first_name, r.last_name, r.email, r.country, e.headline, e.industry, pp.photo FR...

How to select last row of mysql_query?

It is possible to select last row selected by mysql_query in php without iterating using mysql_fetch_row from first row till last? If so, what should I use? ...

How to do this query?

Hello everybody! I have a mysql table with these columns: ID (auto-increment) ID_BOOK (int) PRICE (double) DATA (date) I know two ID_BOOK values, example, 1 and 2. QUERY: I have to extract all the PRICE (of the ID_BOOK=1 and ID_BOOK=2) where DATA is the same! Table example: 1 1 10.00 2010-05-16 2 1 11.00 2010-05-15 3 1 ...

How to display thumbnails with category by category

http://pastie.org/962429 I have the above SQL. There are three categories, webdesign, logos and prints. I want to display them as following html. http://pastie.org/962432 Basically pulling thumbnail image and name from database category by category. I am not really sure how to do it. I will appreciate any inputs or help. Thanks ...

MySQL count elements in a database based on how many unique values there are in a field.

(Sorry for the title, I don't really know how to phrase that :-) ) I have a table that has a date and a uid fields. I need to get the number of uid for each date, currently I'm doing it in php running multiple queries like this one: SELECT COUNT(uid) FROM users where Date = 'xxx'; Is there a simple way to achieve this with only an s...

Database EAV model, record listing as per search

I am building a dynamic application. I have three tables : ( EAV model style) Items ( ItemId, ItemName) Fields (FieldId, FieldName) Field Values ( ItemID, FieldId, Value) Can you tell me how to write SINGLE query to get starting 20 records from ALL items where FieldId=4 is equal to TRUE. Expected Result : Columns => Ite...

Complex data ordering...

Hi, I have one tables ids in an array and they are ordered in the way I want and I have to select data from another table using those ids and in a order they are listen in the array. Pretty confusing but I was thinking of two solutions giving ORDER BY parameter the array but I do not know if that possible and another is to get all the ne...

value from one table and inserted to another in the same database??

I have removed the same. found myself a solution. No answer is required thanks ...

Best way to check for NULL value in MySql query

Can any one please let me know the best way to use IF statement in mysql query to show if the "email" field is NULL then it should show as "no email"... Postcode Telephone Email ---------------------------------------------------------- BS20 0QN 1275373088 no email BS20 0QN 1275373088 no email PO9 4H...

mysql_real_escape more than once

I was just wondering whether it makes a difference if I mysql_real_escape data more than once? So if I escaped data in one part of my website, and then again in another part of code. Would this be a problem? Or make a difference? ...

Insert new row with data computed from other rows

Suppose I have a MySQL table called MyTable, that looks like this: +----+------+-------+ | Id | Type | Value | +----+------+-------+ | 0 | A | 1 | | 0 | B | 1 | | 1 | A | 2 | | 1 | B | 3 | | 2 | A | 5 | | 2 | B | 8 | +----+------+-------+ And, for each Id, I want to insert a new row with...

Problem with auto increment primary key (MySQL).

I have 2 tables each using other's primary key as a foreign key. The primary keys for both are set to auto_increment. The problem is, when I try to create and entry into one of the tables, I have no idea what the primary key of the entry is and can't figure out what to put in the other table as a foreign key. What should I do? Do I drop...

Synchronising local and remote DB

Hi everyone, I have a general question about DB synchronisation. So, I'm developing a website locally (PHP + MySQL) and I would like to be able to synchronise at least the structure (and maybe the contents) of the two DB when one of the two is changed (normally I would change the local copy). Right now what I'm doing is to use mysqldu...

Search and Replace within a Text file using mySQL queries

How can I create PHP to search the testing.txt file for each name in the database table and replace the name with the database table id? So that the text file looks like this: 3 | 1 | 4 | 5 2 | 3 | 6 4 | 5 | 2 and so forth an so on... I have a mysql table called "nameslist" that looks like this: --------------------- id | name -----...

Doctrine Searchable vs. Mysql Fulltext

Hello, I have a CSV file will 3x10^6 rows, title and body mostly, the text file has 3GB+. Im a little scared of the fact that Seachable will almost duplicate the data, can anyone please advise me on the advantages of searchable over a mysql fulltext index on the title, body columns? ...

Mysql maven jpa skeleton

Hi, is there a skeleton for a project using mysql, some eclipse/top link with RESOURCE_LOCAL as connection type? Preferably using maven. I'm searching for it for hours and can't get running even the sipmlest exaple. So if you had it ready and running, please, post :-). Even something as simple as these two classes only. @Entity public c...