Jump to content

FROM `table`


Matpatnik
 Share

Recommended Posts

You can use BETWEEN to get a range.http://dev.mysql.com/doc/refman/4.1/en/com...perator_betweenIf you want to get string fields that contain another string you can use LIKE with the wildcard.get rows starting with 'a':SELECT * FROM table WHERE col LIKE 'a%'get rows ending with 't':SELECT * FROM table WHERE col LIKE '%t'get rows containing 'cat':SELECT * FROM table WHERE col LIKE '%cat%'

Link to comment
Share on other sites

We will have (in a close future) so many information stored in our db so I decide to set it like thathere is my db, we have 936 tbls so 36 tbls of each letter

$start = 97;for ($f=0; $f<26; $f++) {	for ($s=0; $s<123; $s++) {		// ignore character 0-47 and 58-96		// so just keep 0-9 and a-z (no capital letters)		if (($s >= 0 && $s < 48) || ($s > 57 && $s < 97)) {			// skip the rest and continue the for loop			continue;		}				// add a  second character		$lettre = chr($start+$f) . chr($s);				// escape illegal name by doubling the second letter		switch ($lettre) {			case 'as':				$lettre = '######';			break;			case 'by':				$lettre = 'byy';			break;			case 'if':				$lettre = 'iff';			break;			case 'in':				$lettre = 'inn';			break;			case 'is':				$lettre = 'iss';			break;			case 'on':				$lettre = 'onn';			break;			case 'or':				$lettre = 'orr';			break;			case 'to':				$lettre = 'too';			break;		}				$sql = "CREATE TABLE ". $lettre ." (id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY																	...);";			$results = mysql_query($sql)			or die (mysql_error() .' => '. $lettre);	}	echo 'All table '. chr($start+$f) .' successfully created!<br>';}

our problem right now is we are trying to make a button (with VB) that will select all the tables of that specific first letter in the dbwe was thinking of SELECT * FROM a1,a2,a3,a4,a5,a6,a7,a8... but the thing is that it put all the information in 1 row and rename the column like thisid | id_1 | id_2 | id_3 | id_4 | ... we are not sure but we think that can become a problem later

Link to comment
Share on other sites

It sounds like a problem to have 36 tables for each letter of the alphabet. There's no way to use wildcards in table selection, only row selection. The list of table names to select from cannot be an expression, only a list of tables with JOIN syntax.http://dev.mysql.com/doc/refman/4.1/en/select.htmlIt might be better to redesign the database.

Link to comment
Share on other sites

If all the tables are identical then you could just have one table with extra columns that differentiate between letters, then each time you INSERT you just set the values of that column to the required letter sequence.Fewer tables are always better.

Link to comment
Share on other sites

Guest sus4827

Hi,You can get a list of tables with name like 'pattern' . Not sure if this will help you. Just check it out.The query is:select * from sysobjects where name like 'a%';This will list out all the tables starting with letter 'a'.

You can use BETWEEN to get a range.http://dev.mysql.com/doc/refman/4.1/en/com...perator_betweenIf you want to get string fields that contain another string you can use LIKE with the wildcard.get rows starting with 'a':SELECT * FROM table WHERE col LIKE 'a%'get rows ending with 't':SELECT * FROM table WHERE col LIKE '%t'get rows containing 'cat':SELECT * FROM table WHERE col LIKE '%cat%'
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...