mysql-query

frustrating query - news feed like facebook

im trying to have news feed like facebook. Database Dump http://www.2shared.com/document/RXQ13S-n/exported.html i have feed table, which gets feed for text, image or video. i want to group the latest video and images feed and show them as one row and if someone feed comes after it, then group gets break for that row. the following que...

How to optimize an ORDER BY for a computed column on a MASSIVE MySQL table

I have a very large (80+ million row) de-normalized MySQL table. A simplified schema looks like: +-----------+-------------+--------------+--------------+ | ID | PARAM1 | PARAM2 | PARAM3 | +-----------+-------------+--------------+--------------+ | 1 | .04 | .87 | .78 | +-------...

MySQL Sum based on date range and time of day

Hello, I have a large set of data collected every 15 minutes. I am trying to select data between a certain time period and then within that time period divide it up by another date intervals. And within those intervals sum over a certain time period. For example, I would like to be able to select data between 01/01/2009 and 01/01/2...

Access and Change PHP MySQL Fields Easier

I have a PHP web application where users, when logged in, have a bunch of different properties associated with them in a MySQL table. I'd like an easy way to access and change (get/set) those properties. What I want to do is something like this: $obj = mysql_fetch_object(mysql_query("SELECT * FROM users WHERE userid = '$id'")); So the...

mysql subquery in single table

Hi, I have 2 columns in an "entries" table: a non-unique id, and a date stamp (YYYY-MM-DD). I want to select "all of the entry id's that were inserted today that have never been entered before." I've been trying to use a subquery, but I don't think I'm using it right since they're both performed on the same table. Could someone help me ...

Simplifying mysql fulltext search

To do text search for wordA, wordB and wordC right now I'm doing it this way: SELECT * FROM mytable WHERE MATCH (field1) AGAINTS ('wordA' IN BOOLEAN MODE) OR MATCH (field1) AGAINTS ('wordB' IN BOOLEAN MODE) OR MATCH (field1) AGAINTS ('wordC' IN BOOLEAN MODE) Is there a more compact way of writing this? ...

mysql rollback on myisam engine

by mistake i run the update query , This update made my table all rows values as o , Is it possible to rollback the table values , Plz advise ...

Are multiple indices needed for multiple where clauses?

Say I have a query like the following: SELECT * FROM users WHERE username = 'test' AND somethingelse = 'test' I'm wondering if it's necessary to index both columns for optimization. Does MySQL first find all username columns with the value 'test', and then search those results for somethingelse columns with 'test'? Or does it happen s...

How to store data in array in mysql function or procedure

How to store data in array in mysql function or procedure? How to initialize array in mysql? array like array(1=>1,b=>2) is it possible in mysql? ...

MySQL query for rows at specific time intervals

Hi, I am having some confusion with a mysql query. Any help appreciated. My current query: SELECT r.name , r.network , i.name , d.dtime , d.input FROM router AS r INNER JOIN interface AS i ON r.rid = i.rid INNER JOIN 1273118400_1_60 AS d ON i.id = d.id AND dtime BETWEEN 1273152000 AND 1273153800 WHERE i.status = "active" Now I am ...

output sql statement is grouped

Hello everybody, I have a little problem, have the following statement in mysql: SELECT cmfilm.*, cmgenre.titel AS genretitel, cmvertoning.*, cmzaal.titel AS zaaltitel FROM cmfilm LEFT JOIN cmvertoning ON cmvertoning.film_id=cmfilm.id LEFT JOIN cmgenre ON cmfilm.genre_id=cmgenre.id LEFT JOIN cmzaal ON cmvertoning....

Mysql Query Confusion

Hi, I have these tables: domain domain_module domain_module_feature domain_module_feature_to_domain A domain can have many domain_module_feature(s), the domain_module_feature_to_domain table contains 3 columns - dmf_id, dmf_domain_id and dmf_feature_id. For ease of this example lets assume domain has just 2 columns - dm_id and dm_na...

Rails relational issue - Find user's next outing

I have an outings table, which basically holds some information about an 'outing'. These outings then have crews, which have users (through crew_users) Just as a note, outings have many crews, so there's an outing_id in the crews table Now, I need to find the user's next outing, as in the first outing where outing.start_time > Time.n...

Help with MySQL statement

I have written the following SQL statement in MySQL : USE my_database; SELECT * FROM some_table WHERE some_column IN (1, 2, 3); This returns a set of rows that have a column value which is a key into a row of another table (call it some_other_table). a b c d <--this is the column with the key 1 2 3 I want to say, ...

Logged in user, retrieving data from two different tables which have same field names

Hi everyone, Im a PHP/MySQL beginner and I really need some help for the following code (I apologize for the length of it, please bear with me!). I have 3 tables of data in my MSQL database with about 150 users in total. user: Which has the user name, email, password etc thismonth_results: has 25 fields of numerical data, all are popu...

Sql-Query: Hiding letters after space in the output

Hello all, I've got a problem and hope you can help me find a solution. Name Hours title Name1 12 #1 (Text) - text - text Name2 13 #1545 (text) - text - text Name5 19 #33558 (text) - text - text Name6 36 #54123 (text) – text This is an extract from following query: SELECT name AS Name, Sum((Unix_Timestamp(end)-U...

Mysql: How to select distinct values from a database column

Hi friends, My goal is to select value from "EmbedImgDimension" column where in lots of duplicated values are present. I have used the following query select distinct EmbedImgId, VideoID, EmbedImgHeight, EmbedImgWidth, EmbedImgFileName, concat(embedimgwidth,' x ',embedimgheight) as EmbedImgDimension from embedimages inn...

Select from mysql database json objects

I need to store a json string in database and to select entries depending on the values of json object. Is there any way to do this selection using mysql ? (i am using php, mysql 5.1) ...

create array from mysql query php

Hi. I have a little problem that I don't understand. I have a db that has an owner and type (and more off course). I want to get a list of all the type values that has owner equal to the current user, but I get only two result $sql = "SELECT type FROM cars WHERE owner='".mysql_real_escape_string($_SESSION['username'])."' AND selling='0...

Fulltext search in Mysql - illogical behaviour.

I'm getting results that are hard to understand. I hope that someone will be able to shade some light on the subject. I have a very simple table in mysql: id| text 1 | testA testB testC 2 | testA testB When I run the following query: SELECT id, MATCH (text) AGAINST ('+(+testA testB) +testC' IN BOOLEAN MODE) as score FROM test_full...