Sponsored Content
Top Forums Web Development MYSQL: Creating Dynamic Table Names 5.1 Post 302577673 by Astrocloud on Tuesday 29th of November 2011 02:59:52 PM
Old 11-29-2011
Well I removed the hyphens but still get the error:

Code:
Set @BFBW = CONCAT("BFBW", DATE_FORMAT(CURDATE(), '%m%d%Y'));
#Select @BFBW;
CREATE TABLE (SELECT @BFBW) (
  TenantId LONG 
, PostDate DATETIME
, Credit DOUBLE
);

Code:
[Err] 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 '(SELECT @BFBW) (
  TenantId LONG 
, PostDate DATETIME
, Credit DOUBLE
)' at line 2

---------- Post updated at 02:56 PM ---------- Previous update was at 02:55 PM ----------

Quote:
Originally Posted by Corona688
@BFBW is already a value, you don't need select to turn it into one. 'select' just amounts to a 'print' above, you don't need it.
Code:
CREATE TABLE @BFBW
...

Code:
[SQL] 
Set @BFBW = CONCAT("BFBW", DATE_FORMAT(CURDATE(), '%m%d%Y'));
Affected rows: 0
Time: 0.188ms

[SQL] 
#Select @BFBW;
CREATE TABLE @BFBW (
  TenantId LONG 
, PostDate DATETIME
, Credit DOUBLE
);
[Err] 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 '@BFBW (
  TenantId LONG 
, PostDate DATETIME
, Credit DOUBLE
)' at line 2

---------- Post updated at 02:59 PM ---------- Previous update was at 02:56 PM ----------

It just doesn't like the Variable for a table name example:
Code:
Set @BFBW = CONCAT("BFBW", "G");
CREATE TABLE @BFBW (
  TenantId LONG 
, PostDate DATETIME
, Credit DOUBLE
);


Last edited by Scott; 11-29-2011 at 04:20 PM.. Reason: A lot more code tags
 

10 More Discussions You Might Find Interesting

1. AIX

Dynamic routing table

i have AIX Unix with "dynamic routing table" service enabled, but i do not need this service. How i can disable this service. thanks (1 Reply)
Discussion started by: jdsnbr
1 Replies

2. HP-UX

dynamic names for .tar.gz files?

Hi All, I have a requirement to zip and compress files with dynamic names (which includes date and time component in their names) needs to be compressed with same name. for example I have a file T.30.SLS_ORD.SO.27.2_2_2.20080623.041415.dat which needs to archived as... (1 Reply)
Discussion started by: srinivas_paluku
1 Replies

3. Shell Programming and Scripting

creating a dynamic array

i want to create an array the array elements are populated depending upon the number of entries present in a data file The data file is created dynamically how to achieve the same thanks (1 Reply)
Discussion started by: trichyselva
1 Replies

4. Shell Programming and Scripting

need help with creating dynamic tcl displays

I'm fairly new to tcl scripting and could use a little help. I have a simple list file that will be of unknown size (somewhere between 10 to 20 names). I'd like to create a gui that has a checkbutton for each name in the list and a single action button that will do something for all the checkboxes... (0 Replies)
Discussion started by: scottwevans
0 Replies

5. Shell Programming and Scripting

Creating a dynamic case statement

I'm using the korn shell and trying to create a case statement from the contents of a file that is changed regularly, each line of the file has three fields, eg track1 202.111.111.111 99 room7 222.111.222.333 76 I'm using awk to select each variable. I've been unable to figure out how to... (5 Replies)
Discussion started by: squrcles
5 Replies

6. UNIX for Advanced & Expert Users

Sql dynamic table / dynamic inserts

I have a file that reads File (X.txt) Contents of record 1: rdrDESTINATION_ADDRESS (String) "91 971502573813" rdrDESTINATION_IMSI (String) "000000000000000" rdrORIGINATING_ADDRESS (String) "d0 movies" rdrORIGINATING_IMSI (String) "000000000000000" rdrTRAFFIC_EVENT_TIME... (0 Replies)
Discussion started by: magedfawzy
0 Replies

7. Shell Programming and Scripting

Store data from dynamic website table

hi everybody, Asking for something that I´m not sure if it´s possible to implement. I hope be clear enough. Well, my issue is that I´m looking how to copy or extract a particular table content of a website. I get the content from a external feed (Iframe format), the content is updated every... (1 Reply)
Discussion started by: cgkmal
1 Replies

8. UNIX for Dummies Questions & Answers

Creating a condensed table from a pre-existing table in putty

Hello, I'm working with putty on Windows 7 professional and I'd like to know if there's a way to gather specific lines from a pre-existing table and make a new table with that information. More specifically, I'd like the program to look at a specific column, say column N, and see if any of the... (5 Replies)
Discussion started by: Deedee393
5 Replies

9. Shell Programming and Scripting

How to make dynamic variable names for use in while loop?

i=0 while do sizesfor0=`cat 16 | grep 'pickSize' -A 1 | grep '_sz' | cut -d'_' -f1` sizesfor0=${sizesfor0//id=\"lll/:} IFS=: array0=( $sizesfor0 ) echo ${array0} i=$(( $i + 1 )) done So, right now I have two variables in the while statement above sizesfor0 and array0 The... (1 Reply)
Discussion started by: phpchick
1 Replies

10. Shell Programming and Scripting

Matching the header of a .CSV file with dynamic field names

I have a .CSV file (frequency - weekly) whose header contains the year-week value in two of the columns which keeps changing every week. For an instance please see below. Column1,Column2,Column3,Column4,Column5,Column6,Column7,Column8,Column9,Column10,Column11,Column12,Column13,201420... (4 Replies)
Discussion started by: dhruuv369
4 Replies
All times are GMT -4. The time now is 09:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy