V
V
Vadim Voron2015-03-30 22:44:52
PHP
Vadim Voron, 2015-03-30 22:44:52

To select the list of users from 2 tables of a DB?

Good day. The question seems to be banal but still I can not find a solution on the net. Actually an essence - is XML which forms fields for the form of editing of a material. It displays a list of users registered on the site in a drop-down list format.

<field name="name"
  type="sql" 
  default="10" 
  label="Name" 
  query="SELECT name FROM #__users " 
  key_field="name">
</field>

The problem is that the form can be filled with the username of both already registered on the site and not registered - that is, for example, a certain Vasia_user.
The Database has a table #__zakaz in which data is written to the name cell from the drop-down list (if we make an entry from the admin panel) or from the form on the frontend if the user is not authorized on the site. The problem occurs when a user who is not registered on the site makes an order and in the name field is written not user_1 but some Vasia_user - which is not in the list of registered users. Please tell me how to create a query in the database so that in the list of users I would first display Vasia_user and then a list of all registered users.
There are no binding fields between table #__users and #__zakaz
The site is developed on Joomla 3.3

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artyom Karetnikov, 2015-03-31
@vadim_voron

well, how can you not find the answer to this question on the net?
select name from zakaz -- here is your first Vasya.
union -- here is the command we need
select name from users -- here are all other users

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question