0

Is there any option to select a table dynamically from mysql..

For example,

If i have 3 tables like

  1. t_tableconfig
  2. t_2013
  3. t_2014
t_tableconfig contains data like,
tableid  tablename
1         t_2013
2         t_2014
t_2013 contains
id     name
1      David
t_2014 contains
id     name
1      joe

If I will pass a table name as a parameter.. Can I view the records from specified table? Please advice me

Imran
  • 3,031
  • 4
  • 25
  • 41
Vijay Leo
  • 109
  • 2
  • 4
  • 11

2 Answers2

1

It depends on what your programming language or ORM(Object-relational Mapping).

Could you please tell me the environment you're using to query sql statement?

// I've added below

As you said you're using hibernate, I hope the link below can help you. I'm not familiar with hibernate.

Hibernate: Data Object with a dynamic table name by Annotations

Community
  • 1
  • 1
Hosang Jeon
  • 1,373
  • 1
  • 17
  • 37
  • As you said you're using hibernate, I hope the link below can help you. I'm not familiar with hibernate. http://stackoverflow.com/questions/8573468/hibernate-data-object-with-a-dynamic-table-name-by-annotations – Hosang Jeon Dec 21 '13 at 08:47
0

Use redbeans ORM . it's awesome ORM. you can change your table dynamically. You can perform crud operation which you usually use in several tools.

Advantage

  • You can create schema more faster.
  • Magically perform [CRUD](http://en.wikipedia.org/wiki/Create,_read,_update_and_delete) operation
  • That has only 1 php file. It has no criteria to installation.
  • Easy to learn
Imran
  • 3,031
  • 4
  • 25
  • 41