Ok, I find myself doing this often. I'll attach ids to my tables and I'll "link" the tables together. Just a simple example, a team roster might have categories. Each category has an id. When I add players into the roster, I'll assign them a category id as well to signify that they are part of that category.
My question is, for this exa...
I have a timestamp field [SubmissionDate], which defaults to current_timestamp, and i was wondering how do i query my database in such a fashion that for example i get only shown all entries submitted on a certain year and month?
Something like:
SELECT * FROM DNA_entrys
WHERE `SubmissionDate`.month = February
AND `SubmissionDate`.year =...
The MySQL documentation defines index_length as "The length of the index file" but doesn't specify the unit. Is it bytes?
http://dev.mysql.com/doc/refman/5.1/en/show-table-status.html
...
I'm trying to get the code below to work.....
The error:
ERRORSQLSTATE[42000]: Syntax error or access violation: 1064
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax
to use near '?, ?, ?, ?)' at line 1
The code:
$data=array($idApplications,$author,$addedOn,...
I want insert "This is a apple, it is a fruit" to query the database. and only match the words 'apple' and 'fruit' not 'fruits' from the database and return '1 fruit apple red 10'.
How to modify the query code?
Thanks.
database name 'food' fields as below:
id name1 name2 name3 name4 type
1 fruit apple red 10 article
2 fruit banana yell...
since last post, did all the changes suggested but this problem still haunts me. Here's the error i get:
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 44,499,102 milliseconds ago.
here's my hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYP...
Hi,
I'm working on the symfony tutorial jobeet and I have problems to get a database connection to the MySQL-database via doctrine. Development enviroment: Mac OS X and XAMPP.
The command 'php symfony doctrine:build-schema' gives me the following error message:
Warning: PDO::__construct(): [2002] No such file or directory (trying to ...
I am making a simple select from mySQL using PHP. I am doing something wrong that I can't seem to track down.
Here's my statement:
$storyTitle = $_GET['title'];
$storyDate = urldecode($_GET['date']);
$SQL = "SELECT
*
FROM
tblContent
WHERE
REPLACE(contentTitle,' ' , '-') = :storyTitle
AND
date...
I'm trying to migrate from an Access db to a MySql and don't have much experience with the latter.
I wrote some sample code to write data that works one way, but not another and I'm not seeing the difference. Basically, the way that WORKS connects to the MySql database, extracts a dataset, creates a new row of data, adds it to the datas...
To begin with, i should clarify the title, so you really understand what I'm trying to do.
I'm working on a shopping-cart-ish script, but it's a little different because all products (almost always) will be purchased each time. Therefore i believe it's best to list all of the items up with a table, and then let the customer choose the a...
Hello,
I have table (MyISAM) with columns views_total, views_24h, views_7d, views_30d. views_24h = view for last 24 hours, views_7d = last 7 days etc. All this columns are INT and INDEX because I'm doing sorting by them.
Every hour (for 24h), or every day (for 7d, 30d) I'm updating this columns using UPDATE ... JOIN (... UNION ALL ...)...
I'm thinking the problem here is with my SQL Syntax, but I'm not sure and need a fresh pair of eyes to check it out. This is the code I'm using to connect to and then insert into the DB:
OdbcConnection datConn = CreateDataConn();
datConn.Open();
OdbcCommand comm = new OdbcCommand();
comm.CommandTex...
I have a table with fields:
id
name
parent_id
grandparent_id
I want to select the id, name, parent name, grandparent name.
Can I do this with a self join? I basically want to retrieve the "name" value where parent_id = id and return one row.
Example:
id name parent_id grandparent_id
---------------------------------...
I would like to combine these 2 statements but can't seem to get it right.
I need 3 total columns. One for total, month and losses.
Here is what I have so far
SELECT Count(patient1.patient_id) AS total FROM patient AS total;
SELECT Count(patient2.patient_id) AS losses, patient2.mo AS `month`
FROM patient AS patient2
WHERE patient1.rx_...
I'm trying to do the following in MySQL:
SELECT DISTINCT field
FROM table
WHERE COUNT(field) > 10
Which fails with: 1111 - Invalid use of group function (from what I understand, you can't use group functions such as COUNT in the where clause?)
What is the proper way of selecting (distinct) all fields which are present in at least N r...
Do you lose any data when converting a timestamp to datetime in mysql? Also what are the major differences between the two?
...
I am tring to have the selected number showing on the listbox as default.
In the follow database i have
Database Name: ratings
ID ---------------- Rating
1 ---------------- 4
in my list box i have 1 - 10 i want to be able to show the Rating from the database but i want it to display it as default and when you click on the list...
Sample code:
$email = "" . $_POST['email'];
$con = mysql_connect("localhost","user","pass")
or die('Could not connect to database.');
mysql_select_db("face", $con);
// Sanitization step
$sanitemail = mysql_real_escape_string($email);
// Is this safe?
mysql_query("INSERT INTO landing_oct_2010 (email) VALUES ('$sanitemail');");
I'd ...
What exactly happens when the database attached to symfony goes offline or is unreachable? Maybe the answer to this question is in my face and I don't realize it, but I've been searching for the last while and still coming up empty handed.
I've attempted to simulate this myself (in the "production" environment) by just stopping the data...
I installed mysql on ubuntu server and did not specify password. When I do
mysql -u root -p
it prompts for password and without providing any input I just hit enter and it works.
Now I need to perform some operation on the database using cron job. My cron job does not work because mysql prompts for a password. I tried doing
mysql ...