I have a table called 'pages'. Each page has a content type of either text, video or image. Depending on what the content type is a record is also inserted into either text, video or image table.
When I delete a row from 'pages' how can I ensure the rows from the other table is removed? I understand a little about CASCADE but I am not u...
I want to JOIN two table. Have no problem with that. I have problem with quite different thing.
Here's my code:
SELECT * FROM `table1`
JOIN `table2` ON `table1.`field`=`table2`.`field`
...
The main issue is that table1.field is a string, comma-separated. Is there any good and fast way to split it?
Update
I found a function by Federi...
This is a question that has bugged more for a few weeks now and I haven't got around to asking it to you guys.
When I'm selecting data from multiple tables I used to use JOINS a lot and recently I started to use another way but I'm unsure of the impact in the long run.
Examples:
SELECT * FROM table_1 LEFT JOIN table_2 ON (table_1.colu...
I have another case.
I got the bus with 27 seats
then, if people pick the seat 4, so nobody can take that seat 4.
my question:
how design database contain 27 seats? I guess using looping until 27 with PHP
how to show in form, selection form contain the un-booked seat?
how to prevent if other people take same seat?
thanks.
...
Hello,
It is possbile set/reset the AUTO_INCREMENT value of a MySQL table via
ALTER TABLE some_table AUTO_INCREMENT = 1000
However I need to set the AUTO_INCREMENTupon its existing value (to fix M-M replication), something like:
ALTER TABLE some_table SET AUTO_INCREMENT = AUTO_INCREMENT + 1 which is not working
Well actually, I woul...
is there any website which has given very good examples of php5 and mysql.
how to use OOP for website development from small website to large. or is it good to start development in zend framework.
...
I have a pretty large db in MySql, and I need to take backups of it every day or so.
I need to be able to take backups from any computer, so therefore I thought about making a php script to do this and put this php script online (offcourse with password protection and authorization etc so that only I can access it).
I wonder however, h...
Hello
I've been wondering this for a while already. The title stands for my question. What do you prefer?
I made a pic to make my question clearer.
Why am I even thinking of this? Isn't one table the most obvious option? Well, kind of. It's the simpliest way, but let's think more practical. When there is a ton of data in one table a...
I have a mysql dump with 5 databases and would like to know if there is a way to import just one of those (using mysqldump or other).
Suggestions appreciated.
...
Hello.
Will a TEXT field use the same storage space in the database no matter if it is empty, got a few characters or filled to the limit?
...
I'm trying to make my php mysql driven pages as fast as possible.
I've got a fairly standard website with a left-column menu with lists of articles and recipes (loaded from the db) and then on the main content there are some randomly changing articles with clipped previews and also random recipes.
What I've got at the moment is one sql ...
I'm testing some new code to insert into a MySQL database from using PHP. The test
$stmt->execute();
if ($stmt->errorCode() != 0)
{
$arr = $stmt->ErrorInfo();
throw new Exception('SQL failure:'.$arr[0].':'.$arr[1].':'.$arr[2]);
}
It threw a number of errors that I fixed one by one. Finally it dropped through, but nothing was ...
I'm writing some code to automatically tag some articles.
I have an array of tags and a table of articles. I run the following query to check for headlines matching a tag:
SELECT headline
FROM `news`
WHERE MATCH(headline) AGAINST ("+Green +Day" IN BOOLEAN MODE)
This finds all articles with the exact phrase 'Green Day' in the hea...
If I have exported a .sql file with my database in it, can I then only import "parts" of that database instead of the entire database to MySql?
The question appeared when I was trying it out on a test database.
I exported the testdatabase.
Then emptied some of the tables in the database.
Then I planned on importing from the .sql file...
Hello,
I have a mysql query that shows the users last viewed documents. Some sort of history view, and I want to show this in a history tab, but I cannot get this to work.
The history is saved on another server so I'm getting a list of ID's, and I have to get the document's info from the document database. I want it to show duplicate e...
example if i have
follow table
company one ( cid = 1 ) following two ( cid = 2 )
company one ( cid = 1 ) following three( cid = 3 )
feeds table
company one ( cid = 1 ) type 'product' description 'hello ive updated a product';
company two ( cid = 2 ) type 'product' description 'hello ive updated a product im from company 2';
company ...
mysql_query("
SELECT
b.id as b_id
FROM
banner b
INNER JOIN
bannerhits bl
ON
b.id = bl.bannerid
AND
bl.userid = '".$this->userid."'
INNER JOIN
...
Been reading the tutorial How to handle a Many-to-Many relationship with PHP and MySQL .
In this question I refer to the "Database schema" section which states the following rules:
This new table must be constructed to
allow the following:
* It must have a column which links back to table 'A'.
* It must have a column which links ...
Is there a better way to do this?
SELECT subs. * ,
CASE subs.member_type
WHEN 'member' THEN
( SELECT CONCAT_WS( ' ', members.first_name, members.last_name )
FROM members
WHERE members.id = subs.member_id)
ELSE
( SELECT members_anon.username
FROM members_a...
SELECT
b.id as b_id,
b.maxhits as b_maxhits,
b.maxklik as b_maxkli,
b.maxviewsprday as b_maxviewsprday
FROM banner b
JOIN
bannerhits bl
ON
b.id = bl.bannerid
AND
bl.userid = '".$this->userid."'
JOIN
bannerhits blog
ON
...