473,659 Members | 2,985 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Select * from (Right 9 digits on table name)="datatabl e"

8 New Member
I will be querying from many databases and all of the databases that all have a table beginning with word the "DataTable" , but are named differently for example DataTable981911 , DataTable98174, DataTable946. How can I create a select query on table beginning with the word "DataTable" ? Find the table 9 characters in length beginning with the word "DataTable" and then do the select query from it. Thanks for your help.
Mar 4 '08 #1
3 1971
ronverdonk
4,258 Recognized Expert Specialist
As I understand you want the name of all tables beginning with 'datatable' and use these to perform operation on those tables.

You have 2 options:
Expand|Select|Wrap|Line Numbers
  1. SHOW TABLES FROM db_name LIKE 'datatable%';
shows all tables in database 'db_name'
or
Expand|Select|Wrap|Line Numbers
  1. SELECT table_schema, table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_name LIKE 'datatable%';
shows all tables 'table_name' in database 'table_schema'

Ronald
Mar 4 '08 #2
wbw
8 New Member
I am getting tripped up on how to write the From statement. Also how would you deal with aliases when working with multiple tables? Here is an example of my SQL string using a ADODB.Connectio n in VBA-

sSQL = " SELECT a.LDesc, b.ItemID, m.metric1, m.metric2 " & _
" from table_name LIKE 'datatable%' m " & _
" JOIN DimMrkt a ON a.ItemID = m.Mrktkey
" JOIN DimPer b ON b.ItemID = m.Perkey
" GROUP BY a.LDesc, b.ItemID, m.metric1, m.metric2; "
Mar 5 '08 #3
ronverdonk
4,258 Recognized Expert Specialist
I do not understand what are trying to accomplish with that statement. Following your original question there are 2 steps to follow:

1. get names of all tables of which the name starts with 'DataTable' like the statement I showed you, now in a php statement[php]$sql="SELECT table_schema, table_name FROM INFORMATION_SCH EMA.TABLES WHERE table_name LIKE 'datatable%'";
$result=mysql_q uery($sql)
or die ("Select information schema error: ".mysql_error() );
[/php]
2. Then you use the resultset of that select (all table names) to access those tables.
[php]while ($row=mysql_fet ch_assoc($resul t)) {

// get the database name
$database_name= $row['table_schema'];

// get the table name
$tablename=$row['table_name']

// connect to the server
......

// select the database
mysql_select_db ($database);

// do the select on that particular table
$sql1="select .... FROM $tablename .... etc ....";

// process the select
.......
}
[/php]Ronald
Mar 5 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
1792
by: news.microsoft.com | last post by:
We need to take a large amount of data, load it into memory, and then search on it. A hashtable would work if you could perform operations similar to sql select .. where like ... clauses. Any data structure come to mind where I could something like... Object objs = hash; One other question, is it possible to create a hash with multiple keysets? For example, an object, on keyset on name, one on some code?
7
25471
by: TastoEsc | last post by:
I'm working with a dataset table populated with people name which contains "'" and "%" symbols. How can i filter my table with Select method? These symbols aren't supported by a simple string like string name = "Francesc'one"; DataRow filteredRows = ds.Tables.Select("Name = '" + name + "'");
3
1715
by: Fred Nelson | last post by:
Hi: I have created a datatable and I'm able to access it by key values. I need to be able to go to the "top" of the datatable and process records sequentially until they are completed. I can't figure out the command to set me to the top or "beginning" and then read. (datatable.select?)
3
3184
by: Jon | last post by:
I'm learning about datatables. When using the example provided by MS in the ..NET Framework Class Library for DATATABLE (see below) I get an error on line 3 that says "Type expected". Is something missing from the code? Thanks - Jon Private Sub MakeParentTable() ' Create a new DataTable. Dim myDataTable As Datatable = New Datatable("ParentTable")
11
3445
by: Ron L | last post by:
I have a data table that lists a series of items in my database. In my user form, I want the user to be able to filter by a number of criteria (e.g. location, contract, date modified, etc). Other than modified date, all my filters are selected via combo boxes. I would like to have the combo boxes update so that if there are no items available in the currently filtered list for a given selection, that selection will not appear in the...
6
1566
by: Christian Maier | last post by:
Hello! I have huge unperformant "where like" querys to a mysql DB. So there are some performance issues. To resolve my performance problem I thougt to split the query into threads. I hold 10 connections to my database and each connection queries in its own thread as the following: conn1: select fname from root where p_key between 1 and 20000 fname like '%somestring%'; conn2: select fname from root where p_key between 20001 and 40000...
10
24169
by: mcbobin | last post by:
Hi, Here's hoping someone can help... I'm using a stored procedure to return a single row of data ie a DataRow e.g. public static DataRow GetManualDailySplits(string prmLocationID, string
2
1256
by: Fir5tSight | last post by:
Hi, I have a stored procedure that looks like the follows: ------------------------------------------------------------------------------------- SELECT ClientName AS 'Client Name', Location, ReportInstanceID FROM
4
1488
by: Chris Botha | last post by:
The customer has a database with a column in a table named "System". I've been using this method for years now - create a dataset (an .xsd file) for the table. With a column named "System" in the dataset, it gives a substantial number of compile errors. To simplify the problem, add a Dataset with one table and one column called "System" - below follows how it can be done: Right click on the solution, click "Add", click "New Item" and...
0
8335
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8747
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2752
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.