There's a way to get which fields were modified after a update query?
I want to keep track what field XXX user modified... any ways using active records?
How can I do to get the next row in a table?
`image_id` int(11) NOT NULL auto_increment
`image_title` varchar(255) NOT NULL
`image_text` mediumtext NOT NULL
`image_date` datetime NOT NULL
`image_filename` varchar(255) NOT NULL
If the current image is 3 for example and the next one is 7 etc. this won’t work:
$query = mysql_query("SELECT * FROM images WHERE image_id = ".intval($_GET['id']));
echo $_GET['id']+1;
How should I do?
thanks
Hi,
I have the following table in an access database
id VisitNo Weight
1 1 100
1 2 95
1 3 96
1 4 94
1 5 93
Now row 2 and 4 are deleted. So i have...
id VisitNo Weight
1 1 100
1 3 96
1 5 93
However what i need is...
id VisitNo Weight
1 1 100
1 2 96
1 3 93
What is the SQL query i need to accomplish the above?
thanks
Hello,
Using nHibernate, I would like to query on an integer datatype, but its always returning the exact match.
How could I write an expression that returns a list starting with the number entered?
right now I am using it as:
(clientNum is a long)
crit.Add(Expression.Like("ClientNumber", clientNum)); //this always gives me exact matches only
so I tried the following, but its complainging of a wroing type (its only expecting a string)
crit.Add(Expression.Like("ClientNumber", clientNum, MatchMode.Start));
The whole question is pretty much in the title. For each row of the table I'd like to select the maximum of a subset of columns.
For example, from this table
name m1 m2 m3 m4
A 1 2 3 4
B 6 3 4 5
C 1 5 2 1
the result would be
name max
A 4
B 6
C 5
The query must be compatible oracle 8i.
Thanks.
I have a simple query:
SELECT u_name AS user_name FROM users WHERE user_name = "john";
I get "Unknown Column 'user_name' in where clause". Can I not refer to 'user_name' in other parts of the statement even after select 'u_name as user_name'?
i am building a simple PM for my personal website where a user can join and send message to the registered users on my website,
i am stuck in grouping and selecting latest user (by latest msg time) in INBOX page
my table :
id msg_from msg_to msg date in_del out_del
i want to show latest user's id each in a group
here is my SQL query :
SELECT ttalk.id, ttalk.msg_from, users.first_name, users.last_name
FROM ttalk
INNER JOIN users ON ttalk.msg_from = users.id
WHERE ttalk.msg_to = '$_SESSION[user_id]' AND ttalk.in_del='0'
GROUP BY ttalk.msg_from DESC LIMIT 500
Thanks in advance :-)
I'm in need of some help, I need to store the information below into a database, what would the relational database structure be for this:
Then I need to create a dropdown for the insurance company followed by another dropdown depending on what the first dropdown selected value was, then once both selects have been chosen display the relevant telephone number.
I guess i need to query the database, then display the dropdowns using javascript(jquery) or Ajax?
This query generates an error because table2 doesn't exist:
Select * FROM table WHERE table2.id IS NOT NULL
Is there anything like this for check the table2 before apply the check on the id?
Select * FROM table WHERE (EXIST(table2) AND table2.id IS NOT NULL) or not EXIST(table2)
Thanks
I have a java.sql.ResultSet object containg data from a query that was run.
How do I refresh the data in the ResultSet to reflect the current data in the database?
Thanks!
Hi
In my mode I am selecting a field as
$query1 = $this->db->query("SELECT dPassword
FROM tbl_login
WHERE dEmailID='[email protected]'");
How to return dpassword as a variable to my controller
I tried this way return dpassword;
I have a table with products, their amount and their price. I need to select all entries where the average price per article is between a range.
My query so far:
SELECT productid,AVG(SUM(price)/SUM(amount)) AS avg FROM stock WHERE avg=$from AND avg<=$to GROUP BY productid
If do this, it tells me avg doesnt exist.
Also i obviously need to group by because the sum and average need to be per wine
hey
i have the following domain model:
class Location {
String name
static hasMany = [locations:Location, persons:Person]
}
class Person {
String name
}
so basically each location can hold a bunch of people + "sub-locations".
what is the best way to recursively query for all persons under a location (including it's sub locations, and their sub locations, etc')?
hi!
i have 3 tables A,B and C.
table A has column employee_name,id
table B is the main table and has columns id,os version.
table c has the columns id,package id and package version.
i want to query the count of employee_name where the id of table a and c are matched with id of table b(which is the main table).
i should also get the names of employees grouped by the os version they have and also the package version.
I'm trying to take a query:
SHOW TABLES;
which will display a bunch of tables with the chat_ prefix. I want to remove the chat_ prefix from the string, format the variable (with a link), and display it. How is this accomplished?
hello all i hav a table named address which has id, title and parent_id fields. in title column the name of regions and districts are inserted. the regions have parent_id zero and parent_id of the districts are id of the regions. i want a query which display regions in one column and its respective districts in another column. hope u guys understand what i mean..
thank u all.
Is it possible to execute the two update queries in phpmyadmin together?
Like wise
UPDATE jos_menu SET home = 0 WHERE 1;
UPDATE jos_menu SET home = 1 WHERE id = 9;
Now can we copy both these queries together and Run it on phpmyadmin sql query panel?
will it be executed?
I have select, insert, update and delete query.
If I have to write all queries in the same stored procedure that is good for performance or should I write all queries in separate stored procedures?
Suppose a query "select * from employee" returns 80 rows. I need to display middle rows that is from 20th row to 50th row.
I know, like to display first 20 rows we have option like "select top 20 * from employee" but if we need middle rows how to get it in MS SQL specifically.
I m new to this SQL queries...Can anybody answer to this question.
Hi, I'm just wondering how I can retrieve a specific value (only 1 thing will be returned) from a database using php.
My query is
mysql_query("SELECT balance FROM users WHERE username = '". $this->username . "'")
I'm just looking for it to retrieve the data from that row so I can save it directory into a variable.
Hi,
I have the following table in an access database
id VisitNo Weight
1 1 100
1 2 95
1 3 96
1 4 94
1 5 93
Now row 2 and 4 are deleted. So i have...
id VisitNo Weight
1 1 100
1 3 96
1 5 93
However what i need is...
id VisitNo Weight
1 1 100
1 2 96
1 3 93
What is the SQL query i need to accomplish the above?
thanks
I have this query (which I removed some keys from for brevity's sake):
SELECT id as in_id, out_id, recipient, sender, read_flag
FROM received WHERE recipient=1
UNION ALL
SELECT in_id, id AS out_id, recipient, sender, read_flag
FROM sent WHERE sender=1
Which combines the results from two tables showing messages sent and received by a given user. What I'd like to do is add a column/flag to the result to distinguish which table the row belongs to so when I display them I can show a relevant icon for sent or received messages. How would I add this?
i have below table
it_id item_id item_name
1 ite_1 shirt
2 ite_10 pant
3 ite_11 socks
4 ite_12 shoes
5 ite_13 belt
now i need to change item_id with with ite_(value of it_id of that row)
means if it_id=x then item_id should be ite_x and so on...
what will b sql query for that??
Can anyone please clarify what this query will return ?
SELECT TestCase FROM MyTable WHERE Verdict = 'PASS' AND
StartTime > DATE_SUB(NOW(), INTERVAL 2 MONTH)