Is it possible to find if table has layer Or print list of layers? Edit:: I have a table when I selete some data from table like:

Select * from earth where population >100

Then it create new table but if want to hide layer closing table would not work so to hide layer I need to know table that are used to create layer?


If I understand you correctly, I think you want to be able to find out in MapBasic what table a query is based on.

In your queries I would advise adding the into clause to the end of the select statement so you know what the table name is you are dealing with. For eg.

Select * from earth where population >100 into qryName

To determine whether a table is a query or not, you can use the following:

Print TableInfo(qryName, TAB_INFO_TYPE)

If this returns 1 its a base table and if it returns 2 the table is a query.

If the layer is a query, then you can use

Print TableInfo(qryName, TAB_INFO_MAPPABLE_TABLE)

This will tell you which layer the query is based on. But it only works with mappable queries. This is from the MapBasic reference guide:

String result indicating the name of the table containing graphical objects. Use this code when you are working with a table that is actually a relational join of two other tables, and you need to know the name of the base table that contains the graphical objects.

I think for you case this should be fine.

  • Thanks @James Do you mean a query(table) is layer if it is mappable ?
    – kinkajou
    Jul 4 '11 at 15:49
  • In MapInfo you use tables. Tables can be mappable (ie have spatial data). If you add a mappable table to a map window, it becomes a layer in that map window. Query's that have mappable data can also be added as layers to a map window. The layer in the map window will still be based on a MapInfo table.
    – James S
    Jul 4 '11 at 15:59

Use Table List via Layer Control enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.