I have in my SQL Server, a table called FavoriteUsers with a list of users and a table called Users with all users.
In my ASPX page, I have a TextBox where my user can put the ID of an User to list in my GridView.
How it works
By default, I fill my GridView with all data of my FavoriteUsers table, and if the user of my system put some user code in the textbox field and click on my button to find these users, I’ll reload the GridView with the FavoriteUsers and the users that he put on TextBox field that come from the table Users.
How can I do this SELECT query ?
Of course you can’t use TextBox.text in there. But you only needed the query so you get the point.
NOTE: The UNION will leave out any records from Users that already exist in FavoriteUsers. So you won’t have duplicates.