title: select oid from order_details where UserName= '"+uname+"' order by oid desc limit 1
body: <p>What is the syntax error in the query:</p>
  
  <p>select oid from order_details where UserName= '"+uname+"' order by oid desc limit 1;
  Here i am gettin error of syntax.... plz help!!! what is the error???
  Full Code:</p>
  
  <pre><code>&lt;%@page import="javax.validation.constraints.Null"%&gt;
  &lt;%@page import="java.text.SimpleDateFormat"%&gt; 
  &lt;%@page import="java.sql.*"%&gt;
  &lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;title&gt;JSP Page&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
  &lt;%
  String languages;
  int price;
  int tot;
  String[] lang=request.getParameterValues("dish");
  String event=request.getParameter("eve");
  String date=request.getParameter("date");
  String place=request.getParameter("place"); 
  String person=request.getParameter("PERSON");
  String uname=(String)session.getAttribute("username"); 
  String oid="0";
  int row=32;
  Class.forName("com.mysql.jdbc.Driver");
  Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/ready to serve", "root", "");
  Statement st=con.createStatement();
  st.executeUpdate("insert into order_details(event_date,PLACE,NO_OF_PERSON,Event,UserName)values('"+date+"','"+place+"','"+person+"','"+event+"','"+uname+"')");
  String getoid= "select oid from order_details where UserName= '"+uname+"' order by oid desc limit 1";
  
  ResultSet rs= st.executeQuery(getoid);
  if(rs.next())
  {
  oid=rs.getString(1);
  }
  int noof=Integer.parseInt(request.getParameter("PERSON"));
  tot=0;
  ResultSet pric= st.executeQuery("select sum(a.price) from menu a,dorder b where a.dish=b.dish");
  while(pric.next())
  {
  tot=pric.getInt(1)* noof;
  }
  for(int i=0;i&lt;lang.length;i++)
  {
      languages = lang[i];
      st.executeUpdate("insert into dorder values('"+languages+"','"+oid+"','"+uname+"')"); 
  }
  String totin="update order_details set tot='"+tot+"'where oid="+getoid;
  st.executeUpdate(totin);
  out.println("Data is successfully inserted into database.");
  %&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>