I'm trying to use foreign keys properly to maintain data integrity. I'm not really a database guy so I'm wondering if there is some general design principle I don't know about. Here's an example of what I'm trying to do:
Say you want to build a database of vehicles with Type (car, truck, etc.), Make, and Model. A user has to input at le...
Second question in two days on this same sort of topic.
I currently am using the following query:
SELECT name,suite,webpagetest.id,MIN(priority) AS min_pri
FROM webpagetest,comparefileerrors
WHERE vco="aof" AND user="1" AND calibreversion="9"
AND webpagetest.id=comparefileerrors.id
AND comparefileerrors.priority IS NOT NULL
GROUP ...
$db_user="root";
$db_host="localhost";
$db_password="root";
$db_name = "fayer";
$conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die ("couldn't connect to server");
// perform query
$query = 'SELECT * FROM posts';
$result = mysqli_query($conn, $query) or die ("Couldn't execute query.");
// use returned data
while($row...
I am trying to install a Levenshtein UDF for MySQL but I am having a ton of problems, I think mainly because of the lack of documentation for Macs. The specific UDF I am using is this one: http://joshdrew.com/mysql%5Flevenshtein%5Fudf-1.0.tar.gz and is done in C++.
So far, I have gotten successful compilation using:
g++ -Wall -bundle -...
I have been trying to get the Entity Framework to work in my web application using MySQL. It works fine on my local pc, but doesn't work when I put it on the server.
Since the server is a shared server I can install the connector if that is the issue.
...
I used lxml to parse some web page as below:
>>> doc = lxml.html.fromstring(htmldata)
>>> element in doc.cssselect(sometag)[0]
>>> text = element.text_content()
>>> print text
u'Waldenstr\xf6m'
Why it prints u'Waldenstr\xf6m' but not "Waldenström" here?
After that, I tried to add this text to a MySQL table with UTF-8 character set a...
$query = "SELECT posts.*
FROM map, posts, tags
WHERE map.tag_id = tags.id
AND (tags.name IN ('mysql', 'database'))
AND map.post_id = posts.id
GROUP BY posts.id
HAVING COUNT( posts.id ) = 2";
I don't understand the last row. Can someone please explain it for me? What is the difference if I don't have it there?
...
i dont understand one thing. why do i have to use foreign key to link to a primary key in another table?
when i query i type like "where table1.foreignkeycolumn = table2.primarykeycolumn.
does this not work if i havent assigned a foreign key to primarykey?
...
When I'm trying to create a foreign key linked to a primary key in another table I get:
#1452 - Cannot add or update a child row: a foreign key constraint fails
(`fayer`.`#sql-225c_1d3`, CONSTRAINT `#sql-225c_1d3_ibfk_1` FOREIGN KEY (`country_id`)
REFERENCES `countries` (`id`) ON DELETE CASCADE)
I have checked that all tables are usin...
I'm converting an existing table such as this:
CREATE TABLE `example`(`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`column1` char(32) COLLATE latin1_general_ci NOT NULL
DEFAULT '',
`column2` char(64) COLLATE latin1_general_ci NOT NULL
...
Hey,
There is a similar question here but regarding the class path.
http://stackoverflow.com/questions/1585811/classnotfoundexception-com-mysql-jdbc-driver
I've had everything working great until some days ago. Suddenly my little application can't find the mysql driver. And i don't understand why (really I've checked everything)
I got...
First of all, I am using the DATE_ADD function for MySQL. When trying to use $sqlA in php, it saids syntax error for some reason (mainly the area after WHERE). Why?
$sqlA = "SELECT $column_name FROM $table_name WHERE Date >= DATE_ADD(CURDATE(), - INTERVAL 3 DAY)";
However, it works without DATE_ADD:
$sqlB = "SELECT column FROM table...
Okay guys! Right now, I am using Descending for my data because i want the dates from newest to oldest, but I want the entries from that data to be oldest to newest. So how can I do this, especially since I am using DESC in my query. Basically descend the <li> portions
$sql = "SELECT $column_name, DATE(DATEandTIME) as Date FROM Cod...
select userid from cw_users where NOT EXISTS(Select userid from cw_users_data)
The previous query won't do the job of course.
Trying to find only a missing 'userid' from tableb by doing a comparison.
Both tables contain 'userid' and there should be one similar on each. I'm trying to find which one is missing on second table.
...
We use Oracle on a project and would like to also support MySQL. How close are their SQL dialects?
Is it perhaps even possible to use the same SQL source for both without too many gymnastics?
Details:
We're using iBatis, a persistence manager that cleanly segregates the SQL statements into resource files. But we work at the SQL le...
What is the MySQL <=>?
Because the operator is a symbol it is hard to look for documentation. (Similar to the ternary operator ?: for programing languages that support them.)
I got it from an example in a book.
mysql> select null <=> null;
+---------------+
| null <=> null |
+---------------+
| 1 |
+---------------+
1 row...
I need this to be run every 24 hours:
delete tags from tags left join tagowners on tags.id=tagowners.tagId
where tagowners.tagId is null;
...
I am working on some PHP / mysql 5 web project involving a database table that uses not indexed GUID strings as its identifier for rows. So the rows of this product table look like this:
GUID Name
936DA01F-9ABD-4d9d-80C7-02AF85C822A8 Product 1
07c5bcdc-b3a6-482f-8556-bb04fae06538 Product 2
b7b39700-...
Does MySQL (5.0.45) like to do strange internal typecasts with unsigned maths? I am storing integers unsigned but when selecting basic arithmetic I get outrageous numbers:
mysql> create table tt ( a integer unsigned , b integer unsigned , c float );
Query OK, 0 rows affected (0.41 sec)
mysql> insert into tt values (215731,216774,1.580...
Suppose the target database is called "v3"
...