how to get latest date and time in php and mysql using a select statement? is that possible
My field type is data time
it looks like this "2010-06-08 01:41:27" . any help is appreciated guys.
edit:
sorry not so clear with my question...(ugh!)
basically I have a column in my table which has a field of datetime (did I say it right, it has...
I have structure table like this.
the problem is :
When i want to input data to "index" table. I got this error.
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:
Cannot add or update a child row: a
foreign key constraint fails
(test.index, CONSTRAINT
index_ibfk_5 FOREIGN KEY (b_FK)
REFERENCES...
INSERT INTO abc
VALUES (
a, b, c, d, e, f
)
SELECT a, b, c, d, e,f
FROM bcd
when i execute this iam getting synatx errors .how do i get rid of the synatx error
...
I do have 8 tables. when a query fires from search page data from all these 8 tables is pulled out and displayed on the result page. What I want to know is which is the best optimized query method for this process??
what I do now is :
$result = mysql_query("SELECT * FROM TG_dat,TG_dat1,TG_dat2,TG_dat3 WHERE
TG_dat.web = TG_dat1.web A...
What indexes i have to set for a query like this? thanks
SELECT distinct event_dates.* FROM `event_dates`
INNER JOIN `events` ON `events`.id = `event_dates`.event_id
INNER JOIN `cores` ON `cores`.resource_id = `events`.id AND cores.resource_type = 'Event'
INNER JOIN `cores_kinds` ON `cores_kinds`.core_id = `cores`.id
INNER JOIN `kin...
Using EXPLAIN for the query below shows
SELECT cha.cid AS cid,
cha.data AS dl
FROM cha, c_users
WHERE uid = 808
AND cha.cid = c_users.cid;
it does a full scan on cha table
uses the multi column index(cid,uid) from c_users.
Why doesn't it not use the primary key index from cha and rather does a full table scan. Is there a b...
Dear all,
I wanted a guidance for one problem . Suppose i have one table alphabets (alpha, id).
In column alpha having value a-z and in column id all values are 1.
a 1
b 1
. .
. .
z 1
Now i want a database query to insert data like a-z but with id=2 .
Can anybody help me out .
...
Hello,
After I upload a photo to a server, I want to save it in the user's database in MySQL, but for some reason, it is not working. Below is the code for uploader.php:
session_start();
if(!$_SESSION['userid']) {
header("Location: index.php");
exit;
}
$con = mysql_connect("host","db","pw");
if (!$con)
{
die('Could not conne...
Hi!, i'm lookin for a way to make some kind of function into php and mysql who give me as a result the id of a record in a simple table.
I got a id -> value table where the id is an autoincrement field.
The natural way or the simple way i know is:
$myId = Check('Cheese');
function Check($value) {
$sql = "SELECT id FROM table...
I have a query like below...
SELECT
contents.id, contents.title, contents.createdBy,
(SELECT userGroup FROM suser_profile WHERE userId =
(SELECT users.id
FROM
users
WHERE
login = contents.createdBy)
) as userGroupID
FROM
contents
WHERE
contents.id > 0
AND c...
Hello,
I have a rather (I think) easy problem to solve but being a PHP newbie, I can't seem to get the answer...
The query below, print a cloud of tags on my page. I'd like to add "ORDER BY TagID ASC" to this query so that the tags appeared according to their ID #, but I have no idea, where to put it (I didn't write that query, obvious...
I have a table with 4 columns: place_id, username, counter, last_checkin
I'm writing a check-in based system and I'm trying to get a query that will give me the "mayor" of each place. The mayor is the one with most check-ins, and if there is more than 1 than the the minimum last_checkin wins.
For example, if I have:
place_id, username...
I'm looking at making a booking system and I need to display all the available users on a particular day/time.
Thinking about it, I'm going to set up a table to keep note of when people AREN'T available, and assume that they are otherwise available. The structure I had in mind was to keep a note of the date_start of when they won't be a...
i has a table:TestTable, this table only has one field: value,i insert same datas:
value
------------
ccc
aa
111
bbb
------------
i run:
select * from TestTable
can show my result order by:
ccc
aa
111
bbb
now,i want get this result DESC:
bbb
111
aa
ccc
how to create this sql?
select * from TestTable order by (by what?) DESC
...
I have a table that is indexed on the first 2 columns. Column A is called "directory" and Column B is called "name".
Is there short syntax for my select statement that I can use to return the proper row?
Example:
Can I
SELECT * FROM table WHERE indexname = '/dir/sub-dir/page.html'
or do I have to
SELECT * FROM table WHERE director...
Hello All,
I have a slave where i had changed my changed my.cnf ibadata as follows
innodb_data_file_path = ibdata1:1000M:autoextend
before changing this in my.cnf the file size of ibdata1 is : 6.4 G
this was working fine but after restaring the all the tables have been changed from innodb engine to myisam
could any one please expla...
Hi,
I want to get first day of every corresponding month of current year. For example, user selects '2010-06-15', query demands to run from '2010-06-01' instead of '2010-06-15'.
Please help me how to calculate first day from selected date. Currently, I am trying to get desirable using following mysql select query:-
Select DAYOFMONTH(...
I've tried loading a mysql data into vb.net data grid view and it is dynamic. Dynamic meaning, it changes its contents whenever I type different text in the textbox.
How do I do it in a textbox. When I load data into it. I just need to change its contents whenever I try to type a different word on the textbox which I use to search:
Here...
I have 2 tables items and item_relations
items has 4 columns row_id(primary key), story_id, field1 and field2
item_relation stores the relation between each rows in items table it has 2 columns parent_story_id and child_story_id. Both columns store story_id's of rows from items.
A parent item can have many child items and a Child can ...
scenarioi:-
1) User enters an address into a search field. Address maybe zip,state or country
2) Now i have to take that address which may be in any order or which may just contain the country, state or zip and check the database if the the results exists or not.
Any advice on this topic would be awesome
...