aneeb Posted October 5, 2012 Share Posted October 5, 2012 i want to fetch data from multiple tables. they all are similar that is they have same colum names (catalog_product_flat_1,catalog_product_flat_ 2,catalog_product_flat_ 3,catalog_product_flat_ 4.......), but they are not related.Is there any way to do this through stored prcedures or any other way. One more thing these tables will increse in future as the stores of my ecomerce site increases..please help me i am new to this... Link to comment Share on other sites More sharing options...
justsomeguy Posted October 5, 2012 Share Posted October 5, 2012 You can use a union, if that's what you're looking for. Link to comment Share on other sites More sharing options...
aneeb Posted October 5, 2012 Author Share Posted October 5, 2012 How... can you give me some example code or something?? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 5, 2012 Share Posted October 5, 2012 http://www.google.com/search?client=opera&rls=en&q=sql+union&sourceid=opera&ie=utf-8&oe=utf-8&channel=suggest Link to comment Share on other sites More sharing options...
aneeb Posted October 5, 2012 Author Share Posted October 5, 2012 i have multiple tables like 20-25 and they will increase in future, so how can i do that with UNION ? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 5, 2012 Share Posted October 5, 2012 You need to list each table that you want information from, regardless of whether or not it is a union. It may be possible to write multiple queries or a stored procedure that would get all table names and find the ones you're looking for but I don't have experience doing something like that with stored procedures. It wouldn't be difficult to do that by using another script language to get all of the tables, build the query, and then run it. Link to comment Share on other sites More sharing options...
Ancient_Doom Posted October 23, 2012 Share Posted October 23, 2012 You need to list each table that you want information from, regardless of whether or not it is a union. It may be possible to write multiple queries or a stored procedure that would get all table names and find the ones you're looking for but I don't have experience doing something like that with stored procedures. It wouldn't be difficult to do that by using another script language to get all of the tables, build the query, and then run it. you mean build a table of tables? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 29, 2012 Share Posted October 29, 2012 The database already has a table that lists things like databases, tables, fields, etc. It's called information_schema. You can query that table to get metadata about the database and schema. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now