Hi all,
Now I have my website built on PHP & Mysql. Consider this like a forum. Now when a user posts a reply in my website 1 (ex. www.website1.com), I want to be able to show the starting thread and it's related replies in a sister website of mine. I want to do this in a way that it does not show the rest of the page & other page conte...
I currently have 2 tables in a MySql database.
Structure:
messages
id | content | user_id | time
submessages
id | subcontent | msg_id | user_id | time
In the submessages table, column msg_id is a foreign key, referencing the id column in table messages.
Now i need to query from php
$cur_userID = $user->current_id; // current user ...
How to caculate sum of times of my colonne called "timeSpent" having this format: HH:mm
in SQL? I am using MySQL.
the type of my column is Time.
it has this structure
TimeFrom like 10:00:00 12:00:00 02:00:00
TimeUntil 08:00:00 09:15:00 01:15:00
Time spent
total time 03:15:00
...
I have a table with just as ID and a value. Let's say this list have 4 items, such as Apple,Banana, Zuchinni, and Other. I want to sort the list alphabetically, but always have 'Other' be the last option. Is there a way to accomplish this using a query?
...
Possible Duplicate:
calculate a sum of type time using sql
I have 2 columns called TimeFrom and TimeUntill. The duration is calculated in TimeSpent.
The values in the column TimeFrom look like this: 10:00:00
The values in the column TimeUntill look like this: 12:00:00
The TimeSpent column would then have the value: 02:00:00.
...
On the project I am working on, I am stuck with the table structure from Hades. Two things to keep in mind:
I can't change the table structure right now. I'm stuck with it for the time being.
The queries are dynamically generated and not hard coded. So, while I am asking for a query that can pull this data, what I am really working t...
In order to fix a bug, I have to iterate over all the rows in a table, updating a cached count of children to what its real value should be. The structure of the things in the table form a tree.
In rails, the following does what I want:
Thing.all.each do |th|
Thing.connection.update(
"
UPDATE #{Thing.quoted_table_name}
...
Possible Duplicate:
calculate a sum of type time using sql
Third duplicate - please stop & focus on the original question.
RDBMS: mysql
column names: Timefrom,timeuntill, timespent as the following
type of the column:Time.
timefrom timeuntill timespent
10:00:00 12:00:00 02:00:00
08:00:00 ...
I am calling the results form a query to a list on my site based on if the item is "downtown_hosted". This works fine but I would now like to sort that list DESC, but can't seem to get the syntax correct.
Below is what I have:
$result_events = mysql_query("SELECT * FROM events
WHERE downtown='downtown_...
Hi!! I'm having a problem. I'm trying to do a query... I remember that in the past I did something like this but today this query is returning nothing, no error, no data, just nothing... the query is something like this:
SELECT field1, @variableX:=field2
FROM table
WHERE
(SELECT COUNT(fieldA) FROM table2 WHERE fieldB=@variableX A...
I have a query
SELECT foo FROM bar WHERE some_column = ?
Can I get a explain plan from MySQL without filling in a value for the parameter?
...
Hello,
I have a datetime field in mysql table and i am using JPA for persisting data but only date goes in database. Time always shows 00:00:00. What should i do?
I am not doing any manipulation with Date. All i do is to assign new Date() to a variable and store it in database.
What am i doing wrong?
...
i have a system there user(sender) can write a note to friends(receivers), number of receivers>=0. Text of the message is saved in DB and visible to sender and all receivers then they login to system. Sender can add more receivers at any time. More over any of receivers can edit the message and even remove it from DB. For this system i c...
I am not able to start MySQL server on Mac OS X 10.4.11. MySQL was installed using Macports. MySQL was running fine until it suddenly died without any obvious reason.
When running "mysql", I get the error message:
ERROR 2002 (HY000): Can't connect to local MySQL server through
socket '/opt/local/var/run/mysql5/mysqld.sock' (2)
If ...
Assume I have these tables, from which i need to display search results in a browser:
Table: Containers
id | name
1 Big Box
2 Grocery Bag
3 Envelope
4 Zip Lock
Table: Sale
id | date | containerid
1 20100101 1
2 20100102 2
3 20091201 3
4 20091115 4
Table: Items
id | name ...
I have a mysql database with movies as follows:
MOVIES(id,title)
KEYWORDS_TABLE(id,key_id) [id is
referenced to movies.id, key_id is
refernced to keywords.id]
KEYWORDS(id,keyword) //this doesn't matter on my example..
Basically i have movies with their titles and plot keywords for each one, i want to select all movies...
I'm planning on doing a lot of INSERT DELAYED into MyISAM tables. But the tables might not exist yet. Let's say e.g. a new table will exist for each day.
So instead of detecting absence of table in my client and creating then retrying the insert, it seems like a good case for a stored procedure ("function").
Is this possible, and wha...
I have a trigger that checks to see if certain fields changed during the update.
If any of these fields changed I update another table.
I'd like to "break" out of the if conditions as soon as I know that something changed.
Is there a way to do this within a MySQL Trigger?
What I have works, but It seems inefficient.
CREATE TRIGGER pr...
I want to create a function that has a select query inside that can be used against multiple database tables but I can not use a variable as the table name. Can I get around this using a PREPARE statement in the function?
An Example:
FUNCTION `TESTFUNC`(dbTable VARCHAR(25)) RETURNS bigint(20)
BEGIN
DECLARE datereg DATETIME;
DE...
I'm trying to install a Rails app on a Cygwin Rails + WAMP MySQL setup, but rake trows an error :
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Of course, it's trying to connect to MySQL trought a Cygwin socket, and since there's no MySQL server running on Cygwin, it fails.
How do I get Rails to connect to ...