logo
down
shadow

Select distinct categories from database


Select distinct categories from database

By : paul
Date : November 24 2020, 03:41 PM
wish helps you I am designing the back end of an app and I want to get distinct categories from the database.I am using the following query: , You are lacking of the parenthesis, it should be:
code :


Share : facebook icon twitter icon
SELECT categories FROM database using different languages

SELECT categories FROM database using different languages


By : user2554638
Date : March 29 2020, 07:55 AM
may help you . I do not understand how any of the answers actually fixes your problem. For instance, how are you supposed to determine which language to use ?
code :
SELECT  FirstName,
        LastName,
        Name AS Category
    FROM User              U,
         CategoryLanguage  CL
    WHERE U.CategoryId   = CL.CategoryId
    AND   U.LanguageCode = CL.LanguageCode
SELECT  FirstName,
        LastName,
        Name AS Category
    FROM User              U,
         CategoryLanguage  CL
    WHERE U.CategoryId   = CL.CategoryId
    AND   U.LanguageCode = "en"        -- or ${language} from the app layer
    AND   U.CategoryId   = ( SELECT CategoryId 
        FROM  CategoryLanguage 
        WHERE LanguageCode = "en"      -- or ${language} from the app layer
        AND   Name         = "Student" -- or ${category} from the app layer
        )
SQL - Select distinct row with multiple categories

SQL - Select distinct row with multiple categories


By : Fernando Navarrete
Date : March 29 2020, 07:55 AM
With these it helps Use the DISTINCT keyword and left join is useless with your WHERE condition
code :
select DISTINCT
  s.title --columns will be added here such as name of category/ies, author etc.
from story as s
join storyCategory as sc--left join so the uncategorized stories will not be excluded
on s.id = sc.storyId
where sc.categoryId = @selectedCategory --this line is removed when there is no category selected
DECLARE @Stories TABLE(Id INT IDENTITY PRIMARY KEY, NAME NVARCHAR(100) NOT NULL) 
DECLARE @Categories TABLE(Id INT IDENTITY PRIMARY KEY, NAME NVARCHAR(100) NOT NULL) 
DECLARE @Fork TABLE(StoryId INT NOT NULL, CategoryId INT NOT NULL, PRIMARY KEY(StoryId, CategoryId)) 

INSERT @Stories 
VALUES ('Story1'), ('Story2'), ('Story3') 

INSERT @Categories 
VALUES ('Category1'), ('Category2'), ('Category3') 

INSERT @Fork 
VALUES(1,1), (1,2), (3,3), (2,3) 

DECLARE @selectedCategory INT = 3 

select 
s.NAME, 
( 
SELECT c.Name + ',' 
FROM @Categories c 
JOIN @Fork f ON f.CategoryId = c.Id AND f.StoryId = s.Id 
ORDER BY c.Name 
FOR XML PATH('') 
) Categories 
from @stories s
Select distinct categories from a table

Select distinct categories from a table


By : Julius
Date : March 29 2020, 07:55 AM
hope this fix your issue I am not at all sure which solution you would prefer (SQL, VBA, Excel formula) but I think a 'spreadsheet' one is:
Select items from distinct categories, including articles with no category

Select items from distinct categories, including articles with no category


By : farm like
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further You can use union to create a derived table that contains
1 article id per non -1 category All article ids for -1 category
code :
select id from (
    select id from articles
    where category_id <> -1
    group by category_id
    union all
    select id from articles
    where category_id = -1
) t order by rand() limit 3;
select id from (
    select id from (
        select id from articles
        where category_id <> -1
        order by rand()
    ) t 
    group by category_id
    union all
    select id from articles
    where category_id = -1
) t order by rand() limit 3;
Laravel - Form select categories from database

Laravel - Form select categories from database


By : user3724835
Date : March 29 2020, 07:55 AM
To fix the issue you can do You are closing your class="form-control" name="category_id">
Related Posts Related Posts :
  • Stop Continuation Task upon exception thrown from parent task
  • Is there a way to make msbuild write error output to stderr?
  • Unit testing: TDD with POCO Objects with navigation properties (relationship fixup)
  • GridSplitter disables my RowDefinition style
  • Memory leak only in Release mode
  • how to read specified string from url
  • how to store html code EMail template in a string variable or textbox c#
  • Set Selected Date to TimePicker wpf (TimePickers inside DataTemplate)
  • How to draw line in Silverlight Specifying Height?
  • Stored procedure executes but does not update data
  • ASP.NET ListBox Trouble
  • Why does C# also not allow empty conditions in while loops?
  • Unable to get a block of code into my regex match groups
  • What is difference between dbcontext.Add and dbcontext.AddObject
  • How do I update the file version number of C# DLL without recompiling?
  • Value for html control always null
  • HttpClient hangs when timeout is setting (Windows Phone)
  • Handle Multiple Form tag in asp.net page?
  • create word document with html content in c#
  • Confusion about Find And Replace
  • Format sms messages in Clickatell
  • Automated Function Overload
  • String to date in MS Access SQL statement gives type mismatch error
  • ShowDialog exiting on certain events
  • Is there a try Convert.ToInt32... avoiding exceptions
  • How to move wpf application into minimize tray at Window Start-up C#?
  • How to change display format of long variable?
  • How to use Addfields in MongoDB C# Aggregation Pipeline
  • MsTest TestCleanup method not called when an unhandled exception is thrown
  • missing last data when exporting gridview to excel
  • How to add array of objects to List in c#
  • Lambda Expression to order (sort) my list collection
  • Library for displaying music notation
  • How to compare two dictionaries in c# and get the output as True and False after validation
  • specify fields to be serialized with JSON
  • How do you obtain the content of a specific node using XmlDocument in C#?
  • How to ignore the first line in a csv file when you read the csv file in C#
  • c# - Problem calling public void from class
  • How to tell a class which objects it should create? Type vs. object confusion :(
  • Save CheckBox state to xml
  • WIX CAQuietExec NETSH Command Fails
  • Issues sending http put request every 60 seconds to RoR app
  • ConfigurationManager.ConnectionStrings.ConnectionString Issue
  • Real size WPF controls for printing
  • How to cancel properly?
  • C# String multiplication error
  • Using Solrnet and Assigning Attributes with Entity Framework Generated POCOs
  • Regex pattern for single backslash
  • TextBox: insert spaces for credit card number?
  • C# DLL loaded for exe-application is not found when launching similar DLL by rundll32.exe
  • Debug a Windows Service with WCF library
  • Open a file from an external assembly?
  • Servicestack RegistrationFeature Unable to bind request
  • Index was outside the bounds of the array confusion
  • Error in Xml to List code. The ':' character, hexadecimal value 0x3A, cannot be included in a name
  • I am trying to do a while loop with a string conditional statement in C#
  • C# 'Cannot access a disposed object. Object name: 'SslStream'.'
  • How to make Gecko use seperate CookieContainer per instance?
  • C# Advanced form "please wait"
  • Send and Receive data C# using network stream
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org